/* get the Option Values from the entry */
bv = ldap_get_values_len(ld, entry, "sudoOption");
if (bv != NULL) {
- char *cp, *tag;
-
for (p = bv; *p != NULL; p++) {
- cp = (*p)->bv_val;
+ char *cp = (*p)->bv_val;
if (*cp == '!')
cp++;
- tag = NULL;
if (strcmp(cp, "authenticate") == 0)
- tag = (*p)->bv_val[0] == '!' ?
- "NOPASSWD: " : "PASSWD: ";
+ lbuf_append(lbuf, (*p)->bv_val[0] == '!' ?
+ "NOPASSWD: " : "PASSWD: ");
else if (strcmp(cp, "noexec") == 0)
- tag = (*p)->bv_val[0] == '!' ?
- "EXEC: " : "NOEXEC: ";
+ lbuf_append(lbuf, (*p)->bv_val[0] == '!' ?
+ "EXEC: " : "NOEXEC: ");
else if (strcmp(cp, "setenv") == 0)
- tag = (*p)->bv_val[0] == '!' ?
- "NOSETENV: " : "SETENV: ";
- if (tag != NULL)
- lbuf_append(lbuf, tag);
+ lbuf_append(lbuf, (*p)->bv_val[0] == '!' ?
+ "NOSETENV: " : "SETENV: ");
}
ldap_value_free_len(bv);
}
case DEFAULTS_CMND:
continue;
}
- lbuf_append(lbuf, prefix);
if (d->val != NULL) {
- lbuf_append(lbuf, "%s%s", d->var, d->op == '+' ? "+=" :
- d->op == '-' ? "-=" : "=");
+ lbuf_append(lbuf, "%s%s%s", prefix, d->var,
+ d->op == '+' ? "+=" : d->op == '-' ? "-=" : "=");
if (strpbrk(d->val, " \t") != NULL) {
lbuf_append(lbuf, "\"");
lbuf_append_quoted(lbuf, "\"", "%s", d->val);
} else
lbuf_append_quoted(lbuf, SUDOERS_QUOTED, "%s", d->val);
} else
- lbuf_append(lbuf, "%s%s", d->op == FALSE ? "!" : "", d->var);
+ lbuf_append(lbuf, "%s%s%s", prefix,
+ d->op == FALSE ? "!" : "", d->var);
prefix = ", ";
nfound++;
}
char *ofile;
struct timeval omtim;
off_t osize;
- } *tf;
+ } *tf = NULL;
/* Determine user's editor. */
editor = find_editor(&editor_argc, &editor_argv);
return rval;
cleanup:
/* Clean up temp files and return. */
- for (i = 0; i < nfiles; i++) {
- if (tf[i].tfile != NULL)
- unlink(tf[i].tfile);
+ if (tf != NULL) {
+ for (i = 0; i < nfiles; i++) {
+ if (tf[i].tfile != NULL)
+ unlink(tf[i].tfile);
+ }
}
return 1;
}
static void delay __P((double));
static void help __P((void)) __attribute__((__noreturn__));
static void usage __P((int));
-static void *open_io_fd __P((char *pathbuf, int len, const char *suffix));
+static int open_io_fd __P((char *pathbuf, int len, const char *suffix, union io_fd *fdp));
static int parse_timing __P((const char *buf, const char *decimal, int *idx, double *seconds, size_t *nbytes));
#ifdef HAVE_REGCOMP
plen = snprintf(path, sizeof(path), "%s/%.2s/%.2s/%.2s/timing",
session_dir, id, &id[2], &id[4]);
if (plen <= 0 || plen >= sizeof(path))
- errorx(1, "%s/%.2s/%.2s/%.2s/%.2s/timing: %s", session_dir,
+ errorx(1, "%s/%.2s/%.2s/%.2s/timing: %s", session_dir,
id, &id[2], &id[4], strerror(ENAMETOOLONG));
plen -= 7;
/* Open files for replay, applying replay filter for the -f flag. */
for (idx = 0; idx < IOFD_MAX; idx++) {
if (ISSET(replay_filter, 1 << idx) || idx == IOFD_TIMING) {
- io_fds[idx].v = open_io_fd(path, plen, io_fnames[idx]);
- if (io_fds[idx].v == NULL)
+ if (open_io_fd(path, plen, io_fnames[idx], &io_fds[idx]) == -1)
error(1, "unable to open %s", path);
}
}
error(1, "nanosleep: tv_sec %ld, tv_nsec %ld", ts.tv_sec, ts.tv_nsec);
}
-static void *
-open_io_fd(path, len, suffix)
+static int
+open_io_fd(path, len, suffix, fdp)
char *path;
int len;
const char *suffix;
+ union io_fd *fdp;
{
path[len] = '\0';
strlcat(path, suffix, PATH_MAX);
#ifdef HAVE_ZLIB_H
- return gzopen(path, "r");
+ fdp->g = gzopen(path, "r");
+ return fdp->g ? 0 : -1;
#else
- return fopen(path, "r");
+ fdp->f = fopen(path, "r");
+ return fdp->f ? 0 : -1;
#endif
}
usage(1);
}
}
- argc -= optind;
- argv += optind;
- if (argc)
+ /* There should be no other command line arguments. */
+ if (argc - optind != 0)
usage(1);
sudo_setpwent();