char *argv[32];
int argc = 0;
char *klog_prog;
- int ret = 1;
+ int ret = 1; /* ret different than zero means failure */
+ int fd, nbytes;
#if defined(AFS_KERBEROS_ENV)
klog_prog = KLOGKRB;
goto out;
case (0): /* child */
close(0);
- dup(pipedes[0]);
+ fd = dup(pipedes[0]);
close(pipedes[0]);
+ if (fd == -1) {
+ syslog(LOG_ERR, "do_klog: dup failed for pipedes[0]: %s",
+ strerror(errno));
+ exit(1);
+ }
close(1);
- dup(pipedes[1]);
+ fd = dup(pipedes[1]);
close(pipedes[1]);
+ if (fd == -1) {
+ close(0);
+ syslog(LOG_ERR, "do_klog: dup failed for pipedes[1]: %s",
+ strerror(errno));
+ exit(1);
+ }
execv(klog_prog, argv);
/* notreached */
syslog(LOG_ERR, "execv failed: %s", strerror(errno));
close(1);
goto out;
default:
- write(pipedes[1], password, strlen(password));
- write(pipedes[1], "\n", 1);
+ nbytes = write(pipedes[1], password, strlen(password));
+ if (nbytes == -1) {
+ syslog(LOG_ERR,
+ "do_klog: could not write the password into the input of the pipe: %s",
+ strerror(errno));
+ }
+ nbytes = write(pipedes[1], "\n", 1);
+ if (nbytes == -1) {
+ syslog(LOG_ERR,
+ "do_klog: could not write the end-of-line code into the input of the pipe: %s",
+ strerror(errno));
+ }
close(pipedes[0]);
close(pipedes[1]);
if (pid != wait(&status))
putenv((char *)new_envstring);
putenv((char *)new_homestring);
- chdir("/tmp");
+
+ if ((retcode = chdir("/tmp")) != 0) {
+ fprintf(stderr, "chdir returned %d.\n", retcode);
+ exit(1);
+ }
+
printf("Type exit to back out.\n");
return execl("/bin/csh", "/bin/csh", NULL);
}
fputs(m->msg, stdout);
if (r) {
r->resp = malloc(PAM_MAX_RESP_SIZE);
- fgets(r->resp, PAM_MAX_RESP_SIZE, stdin);
+ if (fgets(r->resp, PAM_MAX_RESP_SIZE, stdin) == NULL) {
+ fprintf(stderr, "fgets did not work as expected\n");
+ exit(1);
+ }
r->resp[PAM_MAX_RESP_SIZE - 1] = '\0';
p = &r->resp[strlen(r->resp) - 1];
while (*p == '\n' && p >= r->resp)