/[rdesktop]/sourceforge.net/trunk/rdesktop/readpass.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/readpass.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 96 by astrand, Fri Aug 9 09:11:01 2002 UTC revision 97 by astrand, Fri Aug 9 11:55:39 2002 UTC
# Line 26  Line 26 
26  #include <assert.h>  #include <assert.h>
27  #include <unistd.h>  #include <unistd.h>
28  #include <sys/wait.h>  #include <sys/wait.h>
29    #include <sys/stat.h>
30    #include <fcntl.h>
31    
32  /* Execute specified askpass program and fetch password from standard  /* Execute specified askpass program and fetch password from standard
33     output. Return NULL on failure, otherwise a pointer to the data     output. Return NULL on failure, otherwise a pointer to the data
# Line 39  askpass(char *askpass, const char *msg) Line 41  askpass(char *askpass, const char *msg)
41          char *pass;          char *pass;
42          int p[2], status, ret;          int p[2], status, ret;
43          char buf[1024];          char buf[1024];
44            int devnull;
45    
46          if (fflush(stdout) != 0)          if (fflush(stdout) != 0)
47                  error("askpass: fflush: %s", strerror(errno));                  error("askpass: fflush: %s", strerror(errno));
# Line 62  askpass(char *askpass, const char *msg) Line 65  askpass(char *askpass, const char *msg)
65                          setuid(getuid());                          setuid(getuid());
66                          /* Close read end */                          /* Close read end */
67                          close(p[0]);                          close(p[0]);
68    
69                            /* Setup stdin */
70                            devnull = open("/dev/null", 0, O_RDONLY);
71                            if (dup2(devnull, STDIN_FILENO) < 0)
72                            {
73                                    error("askpass: dup2: %s", strerror(errno));
74                                    exit(1);
75                            }
76                            close(devnull);
77    
78                            /* Setup stdout */
79                          if (dup2(p[1], STDOUT_FILENO) < 0)                          if (dup2(p[1], STDOUT_FILENO) < 0)
80                          {                          {
81                                  error("askpass: dup2: %s", strerror(errno));                                  error("askpass: dup2: %s", strerror(errno));
82                                  exit(1);                                  exit(1);
83                          }                          }
84                            close(p[1]);
85    
86                            /* By now, the following fds are open:
87                               0 -> /dev/null
88                               1 -> pipe write end
89                               2 -> users terminal */
90                          execlp(askpass, askpass, msg, (char *) 0);                          execlp(askpass, askpass, msg, (char *) 0);
91                          error("askpass: exec(%s): %s", askpass, strerror(errno));                          error("askpass: exec(%s): %s", askpass, strerror(errno));
92                          exit(1);                          exit(1);

Legend:
Removed from v.96  
changed lines
  Added in v.97

  ViewVC Help
Powered by ViewVC 1.1.26