2 ** Copyright 2001-2006 Double Precision, Inc. See COPYING for
3 ** distribution information.
7 #include "courier_auth_config.h"
18 #include <sys/types.h>
22 #include "authchangepwdir.h"
23 #include "numlib/numlib.h"
26 static int dochangepwd(struct passwd
*, const char *, const char *);
28 int auth_syspasswd(const char *service
, /* Ignored */
29 const char *userid
, /* Generally ignored */
30 const char *oldpwd
, /* Old password */
31 const char *newpwd
) /* New password */
33 char *cpy
=strdup(userid
);
60 rc
=dochangepwd(pwd
, oldpwd
, newpwd
);
66 return (1); /* Fatal error */
69 #define EXPECT AUTHCHANGEPWDIR "/authsystem.passwd"
71 static int dochangepwd(struct passwd
*pwd
,
72 const char *oldpwd
, const char *newpwd
)
79 signal(SIGCHLD
, SIG_DFL
);
80 signal(SIGTERM
, SIG_DFL
);
84 perror("CRIT: authsyschangepwd: pipe() failed");
95 perror("CRIT: authsyschangepwd: fork() failed");
109 open("/dev/null", O_WRONLY
);
112 if (pwd
->pw_uid
!= getuid())
123 setlogin(pwd
->pw_name
);
125 libmail_changeuidgid(pwd
->pw_uid
, pwd
->pw_gid
);
131 execv(argv
[0], argv
);
137 signal(SIGPIPE
, SIG_IGN
);
139 if ((fp
=fdopen(pipefd
[1], "w")) == NULL
)
141 perror("CRIT: authsyschangepwd: fdopen() failed");
146 fprintf(fp
, "%s\n%s\n", oldpwd
, newpwd
);
151 while ((p2
=wait(&waitstat
)) != p
)
153 if (p2
< 0 && errno
== ECHILD
)
155 perror("CRIT: authsyschangepwd: wait() failed");
161 if (WIFEXITED(waitstat
) && WEXITSTATUS(waitstat
) == 0)