Changeset 1289:8bb644107e21 in roaraudio


Ignore:
Timestamp:
03/12/09 01:49:00 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

completed the code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/sshaskpass.c

    r1288 r1289  
    3737int roar_sshaskpass_getpass   (char ** pw, char * desc) { 
    3838#ifdef ROAR_HAVE_BIN_SSH_ASKPASS 
    39  FILE * pipe; 
     39 FILE * cpipe; 
     40 char   buf[1024]; 
     41 int    pos; 
    4042 
    41  if ( (pipe = popen(ROAR_HAVE_BIN_SSH_ASKPASS, "r")) == NULL ) { 
     43 if ( pw == NULL ) 
     44  return -1; 
     45 
     46 if ( (cpipe = popen(ROAR_HAVE_BIN_SSH_ASKPASS, "r")) == NULL ) { 
    4247  return -1; 
    4348 } 
    4449 
    45  fclose(pipe); 
     50 if ( fgets(buf, 1024, cpipe) == NULL ) { 
     51  fclose(cpipe); 
     52  return -1; 
     53 } 
     54 
     55 fclose(cpipe); 
     56 
     57 pos = strlen(buf); 
     58 
     59 for (; pos > -1 && (buf[pos] == '\r' || buf[pos] == '\n'); pos--) 
     60  buf[pos] = 0; 
     61 
     62 if ( pos == 0 ) 
     63  return -1; 
     64 
     65 *pw = strdup(buf); 
     66 
     67 return 0; 
    4668#else 
    4769 return -1; 
Note: See TracChangeset for help on using the changeset viewer.