Annotation of embedaddon/sudo/plugins/sudoers/testsudoers.c, revision 1.1.1.3
1.1 misho 1: /*
1.1.1.2 misho 2: * Copyright (c) 1996, 1998-2005, 2007-2012
1.1 misho 3: * Todd C. Miller <Todd.Miller@courtesan.com>
4: *
5: * Permission to use, copy, modify, and distribute this software for any
6: * purpose with or without fee is hereby granted, provided that the above
7: * copyright notice and this permission notice appear in all copies.
8: *
9: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
17: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18: *
19: * Sponsored in part by the Defense Advanced Research Projects
20: * Agency (DARPA) and Air Force Research Laboratory, Air Force
21: * Materiel Command, USAF, under agreement number F39502-99-1-0512.
22: */
23:
24: #define _SUDO_MAIN
25:
26: #include <config.h>
27:
28: #include <sys/param.h>
29: #include <sys/types.h>
30: #include <sys/stat.h>
31: #include <sys/socket.h>
32: #include <stdio.h>
33: #ifdef STDC_HEADERS
34: # include <stdlib.h>
35: # include <stddef.h>
36: #else
37: # ifdef HAVE_STDLIB_H
38: # include <stdlib.h>
39: # endif
40: #endif /* STDC_HEADERS */
41: #ifdef HAVE_STRING_H
42: # include <string.h>
43: #endif /* HAVE_STRING_H */
44: #ifdef HAVE_STRINGS_H
45: # include <strings.h>
46: #endif /* HAVE_STRINGS_H */
47: #ifdef HAVE_UNISTD_H
48: # include <unistd.h>
49: #endif /* HAVE_UNISTD_H */
50: #ifdef HAVE_FNMATCH
51: # include <fnmatch.h>
1.1.1.2 misho 52: #else
53: # include "compat/fnmatch.h"
1.1 misho 54: #endif /* HAVE_FNMATCH */
55: #ifdef HAVE_NETGROUP_H
56: # include <netgroup.h>
57: #endif /* HAVE_NETGROUP_H */
58: #include <ctype.h>
59: #include <errno.h>
60: #include <netinet/in.h>
61: #include <arpa/inet.h>
62: #include <netdb.h>
1.1.1.2 misho 63: #ifdef HAVE_SETLOCALE
64: # include <locale.h>
65: #endif
1.1 misho 66:
67: #include "tsgetgrpw.h"
68: #include "sudoers.h"
69: #include "interfaces.h"
70: #include "parse.h"
1.1.1.2 misho 71: #include "sudo_conf.h"
1.1.1.3 ! misho 72: #include "secure_path.h"
1.1 misho 73: #include <gram.h>
74:
75: /*
76: * Function Prototypes
77: */
78: int print_alias(void *, void *);
79: void dump_sudoers(void);
80: void print_defaults(void);
81: void print_privilege(struct privilege *);
82: void print_userspecs(void);
83: void usage(void) __attribute__((__noreturn__));
84: void cleanup(int);
85: static void set_runaspw(const char *);
86: static void set_runasgr(const char *);
87: static int cb_runas_default(const char *);
88: static int testsudoers_printf(int msg_type, const char *fmt, ...);
89: static int testsudoers_print(const char *msg);
90:
91: extern void setgrfile(const char *);
92: extern void setgrent(void);
93: extern void endgrent(void);
94: extern struct group *getgrent(void);
95: extern struct group *getgrnam(const char *);
96: extern struct group *getgrgid(gid_t);
97: extern void setpwfile(const char *);
98: extern void setpwent(void);
99: extern void endpwent(void);
100: extern struct passwd *getpwent(void);
101: extern struct passwd *getpwnam(const char *);
102: extern struct passwd *getpwuid(uid_t);
103:
104: extern int (*trace_print)(const char *msg);
105:
106: /*
107: * Globals
108: */
109: struct interface *interfaces;
110: struct sudo_user sudo_user;
111: struct passwd *list_pw;
112: static char *runas_group, *runas_user;
1.1.1.2 misho 113: extern int errorlineno;
114: extern bool parse_error;
115: extern char *errorfile;
1.1 misho 116: sudo_printf_t sudo_printf = testsudoers_printf;
1.1.1.2 misho 117: sudo_conv_t sudo_conv; /* NULL in non-plugin */
1.1 misho 118:
119: /* For getopt(3) */
120: extern char *optarg;
121: extern int optind;
122:
123: #if defined(SUDO_DEVEL) && defined(__OpenBSD__)
124: extern char *malloc_options;
125: #endif
126: #ifdef YYDEBUG
127: extern int yydebug;
128: #endif
129:
130: int
131: main(int argc, char *argv[])
132: {
133: struct cmndspec *cs;
134: struct privilege *priv;
135: struct userspec *us;
136: char *p, *grfile, *pwfile;
137: char hbuf[MAXHOSTNAMELEN + 1];
138: int match, host_match, runas_match, cmnd_match;
1.1.1.2 misho 139: int ch, dflag, exitcode = 0;
140: debug_decl(main, SUDO_DEBUG_MAIN)
1.1 misho 141:
142: #if defined(SUDO_DEVEL) && defined(__OpenBSD__)
143: malloc_options = "AFGJPR";
144: #endif
145: #ifdef YYDEBUG
146: yydebug = 1;
147: #endif
148:
149: #if !defined(HAVE_GETPROGNAME) && !defined(HAVE___PROGNAME)
150: setprogname(argc > 0 ? argv[0] : "testsudoers");
151: #endif
152:
1.1.1.2 misho 153: #ifdef HAVE_SETLOCALE
154: setlocale(LC_ALL, "");
155: #endif
156: bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have own domain */
157: textdomain("sudoers");
158:
159: /* Read sudo.conf. */
160: sudo_conf_read();
161:
1.1 misho 162: dflag = 0;
163: grfile = pwfile = NULL;
1.1.1.3 ! misho 164: while ((ch = getopt(argc, argv, "dg:G:h:P:p:tu:U:")) != -1) {
1.1 misho 165: switch (ch) {
166: case 'd':
167: dflag = 1;
168: break;
169: case 'h':
170: user_host = optarg;
171: break;
172: case 'G':
1.1.1.3 ! misho 173: sudoers_gid = (gid_t)atoi(optarg);
1.1 misho 174: break;
175: case 'g':
176: runas_group = optarg;
177: break;
178: case 'p':
179: pwfile = optarg;
180: break;
1.1.1.3 ! misho 181: case 'P':
! 182: grfile = optarg;
! 183: break;
1.1 misho 184: case 't':
185: trace_print = testsudoers_print;
186: break;
1.1.1.3 ! misho 187: case 'U':
! 188: sudoers_uid = (uid_t)atoi(optarg);
! 189: break;
1.1 misho 190: case 'u':
191: runas_user = optarg;
192: break;
193: default:
194: usage();
195: break;
196: }
197: }
198: argc -= optind;
199: argv += optind;
200:
201: /* Set group/passwd file and init the cache. */
202: if (grfile)
203: setgrfile(grfile);
204: if (pwfile)
205: setpwfile(pwfile);
206: sudo_setpwent();
207: sudo_setgrent();
208:
209: if (argc < 2) {
210: if (!dflag)
211: usage();
1.1.1.2 misho 212: user_name = argc ? *argv++ : "root";
1.1 misho 213: user_cmnd = user_base = "true";
1.1.1.2 misho 214: argc = 0;
1.1 misho 215: } else {
1.1.1.2 misho 216: user_name = *argv++;
217: user_cmnd = *argv++;
1.1 misho 218: if ((p = strrchr(user_cmnd, '/')) != NULL)
219: user_base = p + 1;
220: else
221: user_base = user_cmnd;
222: argc -= 2;
223: }
224: if ((sudo_user.pw = sudo_getpwnam(user_name)) == NULL)
225: errorx(1, _("unknown user: %s"), user_name);
226:
227: if (user_host == NULL) {
228: if (gethostname(hbuf, sizeof(hbuf)) != 0)
229: error(1, "gethostname");
230: hbuf[sizeof(hbuf) - 1] = '\0';
231: user_host = hbuf;
232: }
233: if ((p = strchr(user_host, '.'))) {
234: *p = '\0';
235: user_shost = estrdup(user_host);
236: *p = '.';
237: } else {
238: user_shost = user_host;
239: }
240:
241: /* Fill in user_args from argv. */
242: if (argc > 0) {
243: char *to, **from;
244: size_t size, n;
245:
1.1.1.2 misho 246: for (size = 0, from = argv; *from; from++)
1.1 misho 247: size += strlen(*from) + 1;
248:
249: user_args = (char *) emalloc(size);
1.1.1.2 misho 250: for (to = user_args, from = argv; *from; from++) {
1.1 misho 251: n = strlcpy(to, *from, size - (to - user_args));
252: if (n >= size - (to - user_args))
1.1.1.3 ! misho 253: errorx(1, _("internal error, %s overflow"), "init_vars()");
1.1 misho 254: to += n;
255: *to++ = ' ';
256: }
257: *--to = '\0';
258: }
259:
260: /* Initialize default values. */
261: init_defaults();
262:
263: /* Set runas callback. */
264: sudo_defs_table[I_RUNAS_DEFAULT].callback = cb_runas_default;
265:
266: /* Load ip addr/mask for each interface. */
267: if (get_net_ifs(&p) > 0)
268: set_interfaces(p);
269:
270: /* Allocate space for data structures in the parser. */
1.1.1.3 ! misho 271: init_parser("sudoers", false);
1.1 misho 272:
273: if (yyparse() != 0 || parse_error) {
1.1.1.2 misho 274: parse_error = true;
275: if (errorlineno != -1)
276: (void) printf("Parse error in %s near line %d",
277: errorfile, errorlineno);
278: else
279: (void) printf("Parse error in %s", errorfile);
1.1 misho 280: } else {
281: (void) fputs("Parses OK", stdout);
282: }
283:
284: if (!update_defaults(SETDEF_ALL))
285: (void) fputs(" (problem with defaults entries)", stdout);
286: puts(".");
287:
1.1.1.2 misho 288: if (def_group_plugin && group_plugin_load(def_group_plugin) != true)
1.1 misho 289: def_group_plugin = NULL;
290:
291: /*
292: * Set runas passwd/group entries based on command line or sudoers.
293: * Note that if runas_group was specified without runas_user we
294: * defer setting runas_pw so the match routines know to ignore it.
295: */
296: if (runas_group != NULL) {
297: set_runasgr(runas_group);
298: if (runas_user != NULL)
299: set_runaspw(runas_user);
300: } else
301: set_runaspw(runas_user ? runas_user : def_runas_default);
302:
303: if (dflag) {
304: (void) putchar('\n');
305: dump_sudoers();
1.1.1.2 misho 306: if (argc < 2) {
307: exitcode = parse_error ? 1 : 0;
308: goto done;
309: }
1.1 misho 310: }
311:
312: /* This loop must match the one in sudo_file_lookup() */
313: printf("\nEntries for user %s:\n", user_name);
314: match = UNSPEC;
315: tq_foreach_rev(&userspecs, us) {
316: if (userlist_matches(sudo_user.pw, &us->users) != ALLOW)
317: continue;
318: tq_foreach_rev(&us->privileges, priv) {
319: putchar('\n');
320: print_privilege(priv); /* XXX */
321: putchar('\n');
322: host_match = hostlist_matches(&priv->hostlist);
323: if (host_match == ALLOW) {
324: puts("\thost matched");
325: tq_foreach_rev(&priv->cmndlist, cs) {
326: runas_match = runaslist_matches(&cs->runasuserlist,
1.1.1.3 ! misho 327: &cs->runasgrouplist, NULL, NULL);
1.1 misho 328: if (runas_match == ALLOW) {
329: puts("\trunas matched");
330: cmnd_match = cmnd_matches(cs->cmnd);
331: if (cmnd_match != UNSPEC)
332: match = cmnd_match;
333: printf("\tcmnd %s\n", match == ALLOW ? "allowed" :
334: match == DENY ? "denied" : "unmatched");
335: }
336: }
337: } else
338: puts(_("\thost unmatched"));
339: }
340: }
341: puts(match == ALLOW ? _("\nCommand allowed") :
342: match == DENY ? _("\nCommand denied") : _("\nCommand unmatched"));
343:
344: /*
345: * Exit codes:
346: * 0 - parsed OK and command matched.
347: * 1 - parse error
348: * 2 - command not matched
349: * 3 - command denied
350: */
1.1.1.2 misho 351: exitcode = parse_error ? 1 : (match == ALLOW ? 0 : match + 3);
352: done:
353: sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys, exitcode);
354: exit(exitcode);
1.1 misho 355: }
356:
357: static void
358: set_runaspw(const char *user)
359: {
1.1.1.2 misho 360: debug_decl(main, SUDO_DEBUG_UTIL)
361:
1.1 misho 362: if (runas_pw != NULL)
1.1.1.3 ! misho 363: sudo_pw_delref(runas_pw);
1.1 misho 364: if (*user == '#') {
365: if ((runas_pw = sudo_getpwuid(atoi(user + 1))) == NULL)
366: runas_pw = sudo_fakepwnam(user, runas_gr ? runas_gr->gr_gid : 0);
367: } else {
368: if ((runas_pw = sudo_getpwnam(user)) == NULL)
369: errorx(1, _("unknown user: %s"), user);
370: }
1.1.1.2 misho 371:
372: debug_return;
1.1 misho 373: }
374:
375: static void
376: set_runasgr(const char *group)
377: {
1.1.1.2 misho 378: debug_decl(main, SUDO_DEBUG_UTIL)
379:
1.1 misho 380: if (runas_gr != NULL)
1.1.1.3 ! misho 381: sudo_gr_delref(runas_gr);
1.1 misho 382: if (*group == '#') {
383: if ((runas_gr = sudo_getgrgid(atoi(group + 1))) == NULL)
384: runas_gr = sudo_fakegrnam(group);
385: } else {
386: if ((runas_gr = sudo_getgrnam(group)) == NULL)
387: errorx(1, _("unknown group: %s"), group);
388: }
1.1.1.2 misho 389:
390: debug_return;
1.1 misho 391: }
392:
393: /*
394: * Callback for runas_default sudoers setting.
395: */
396: static int
397: cb_runas_default(const char *user)
398: {
399: /* Only reset runaspw if user didn't specify one. */
400: if (!runas_user && !runas_group)
401: set_runaspw(user);
1.1.1.2 misho 402: return true;
1.1 misho 403: }
404:
405: void
406: sudo_setspent(void)
407: {
408: return;
409: }
410:
411: void
412: sudo_endspent(void)
413: {
414: return;
415: }
416:
417: void
418: set_fqdn(void)
419: {
420: return;
421: }
422:
423: FILE *
1.1.1.3 ! misho 424: open_sudoers(const char *sudoers, bool doedit, bool *keepopen)
1.1 misho 425: {
1.1.1.3 ! misho 426: struct stat sb;
! 427: FILE *fp = NULL;
! 428: char *sudoers_base;
1.1.1.2 misho 429: debug_decl(open_sudoers, SUDO_DEBUG_UTIL)
430:
1.1.1.3 ! misho 431: sudoers_base = strrchr(sudoers, '/');
! 432: if (sudoers_base != NULL)
! 433: sudoers_base++;
! 434:
! 435: switch (sudo_secure_file(sudoers, sudoers_uid, sudoers_gid, &sb)) {
! 436: case SUDO_PATH_SECURE:
! 437: fp = fopen(sudoers, "r");
! 438: break;
! 439: case SUDO_PATH_MISSING:
! 440: warning("unable to stat %s", sudoers_base);
! 441: break;
! 442: case SUDO_PATH_BAD_TYPE:
! 443: warningx("%s is not a regular file", sudoers_base);
! 444: break;
! 445: case SUDO_PATH_WRONG_OWNER:
! 446: warningx("%s should be owned by uid %u",
! 447: sudoers_base, (unsigned int) sudoers_uid);
! 448: break;
! 449: case SUDO_PATH_WORLD_WRITABLE:
! 450: warningx("%s is world writable", sudoers_base);
! 451: break;
! 452: case SUDO_PATH_GROUP_WRITABLE:
! 453: warningx("%s should be owned by gid %u",
! 454: sudoers_base, (unsigned int) sudoers_gid);
! 455: break;
! 456: default:
! 457: /* NOTREACHED */
! 458: break;
! 459: }
! 460:
! 461: debug_return_ptr(fp);
1.1 misho 462: }
463:
464: void
465: init_envtables(void)
466: {
467: return;
468: }
469:
470: int
471: set_perms(int perm)
472: {
473: return 1;
474: }
475:
476: void
477: restore_perms(void)
478: {
479: }
480:
481: void
482: cleanup(int gotsignal)
483: {
484: if (!gotsignal) {
485: sudo_endpwent();
486: sudo_endgrent();
487: }
488: }
489:
490: void
491: print_member(struct member *m)
492: {
493: struct sudo_command *c;
1.1.1.2 misho 494: debug_decl(print_member, SUDO_DEBUG_UTIL)
1.1 misho 495:
496: if (m->negated)
497: putchar('!');
498: if (m->name == NULL)
499: fputs("ALL", stdout);
500: else if (m->type != COMMAND)
501: fputs(m->name, stdout);
502: else {
503: c = (struct sudo_command *) m->name;
504: printf("%s%s%s", c->cmnd, c->args ? " " : "",
505: c->args ? c->args : "");
506: }
1.1.1.2 misho 507:
508: debug_return;
1.1 misho 509: }
510:
511: void
512: print_defaults(void)
513: {
514: struct defaults *d;
515: struct member *m;
1.1.1.2 misho 516: debug_decl(print_member, SUDO_DEBUG_UTIL)
1.1 misho 517:
518: tq_foreach_fwd(&defaults, d) {
519: (void) fputs("Defaults", stdout);
520: switch (d->type) {
521: case DEFAULTS_HOST:
522: putchar('@');
523: break;
524: case DEFAULTS_USER:
525: putchar(':');
526: break;
527: case DEFAULTS_RUNAS:
528: putchar('>');
529: break;
530: case DEFAULTS_CMND:
531: putchar('!');
532: break;
533: }
534: tq_foreach_fwd(&d->binding, m) {
535: if (m != tq_first(&d->binding))
536: putchar(',');
537: print_member(m);
538: }
1.1.1.2 misho 539: printf("\t%s%s", d->op == false ? "!" : "", d->var);
1.1 misho 540: if (d->val != NULL) {
1.1.1.2 misho 541: printf("%c%s", d->op == true ? '=' : d->op, d->val);
1.1 misho 542: }
543: putchar('\n');
544: }
1.1.1.2 misho 545:
546: debug_return;
1.1 misho 547: }
548:
549: int
550: print_alias(void *v1, void *v2)
551: {
552: struct alias *a = (struct alias *)v1;
553: struct member *m;
554: struct sudo_command *c;
1.1.1.2 misho 555: debug_decl(print_alias, SUDO_DEBUG_UTIL)
1.1 misho 556:
557: switch (a->type) {
558: case HOSTALIAS:
559: (void) printf("Host_Alias\t%s = ", a->name);
560: break;
561: case CMNDALIAS:
562: (void) printf("Cmnd_Alias\t%s = ", a->name);
563: break;
564: case USERALIAS:
565: (void) printf("User_Alias\t%s = ", a->name);
566: break;
567: case RUNASALIAS:
568: (void) printf("Runas_Alias\t%s = ", a->name);
569: break;
570: }
571: tq_foreach_fwd(&a->members, m) {
572: if (m != tq_first(&a->members))
573: fputs(", ", stdout);
574: if (m->type == COMMAND) {
575: c = (struct sudo_command *) m->name;
576: printf("%s%s%s", c->cmnd, c->args ? " " : "",
577: c->args ? c->args : "");
578: } else if (m->type == ALL) {
579: fputs("ALL", stdout);
580: } else {
581: fputs(m->name, stdout);
582: }
583: }
584: putchar('\n');
1.1.1.2 misho 585: debug_return_int(0);
1.1 misho 586: }
587:
588: void
589: print_privilege(struct privilege *priv)
590: {
591: struct cmndspec *cs;
592: struct member *m;
593: struct privilege *p;
594: struct cmndtag tags;
1.1.1.2 misho 595: debug_decl(print_privilege, SUDO_DEBUG_UTIL)
1.1 misho 596:
597: for (p = priv; p != NULL; p = p->next) {
598: if (p != priv)
599: fputs(" : ", stdout);
600: tq_foreach_fwd(&p->hostlist, m) {
601: if (m != tq_first(&p->hostlist))
602: fputs(", ", stdout);
603: print_member(m);
604: }
605: fputs(" = ", stdout);
606: tags.nopasswd = tags.noexec = UNSPEC;
607: tq_foreach_fwd(&p->cmndlist, cs) {
608: if (cs != tq_first(&p->cmndlist))
609: fputs(", ", stdout);
610: if (!tq_empty(&cs->runasuserlist) || !tq_empty(&cs->runasgrouplist)) {
611: fputs("(", stdout);
612: if (!tq_empty(&cs->runasuserlist)) {
613: tq_foreach_fwd(&cs->runasuserlist, m) {
614: if (m != tq_first(&cs->runasuserlist))
615: fputs(", ", stdout);
616: print_member(m);
617: }
618: } else if (tq_empty(&cs->runasgrouplist)) {
619: fputs(def_runas_default, stdout);
620: } else {
621: fputs(sudo_user.pw->pw_name, stdout);
622: }
623: if (!tq_empty(&cs->runasgrouplist)) {
624: fputs(" : ", stdout);
625: tq_foreach_fwd(&cs->runasgrouplist, m) {
626: if (m != tq_first(&cs->runasgrouplist))
627: fputs(", ", stdout);
628: print_member(m);
629: }
630: }
631: fputs(") ", stdout);
632: }
633: #ifdef HAVE_SELINUX
634: if (cs->role)
635: printf("ROLE=%s ", cs->role);
636: if (cs->type)
637: printf("TYPE=%s ", cs->type);
638: #endif /* HAVE_SELINUX */
1.1.1.3 ! misho 639: #ifdef HAVE_PRIV_SET
! 640: if (cs->privs)
! 641: printf("PRIVS=%s ", cs->privs);
! 642: if (cs->limitprivs)
! 643: printf("LIMITPRIVS=%s ", cs->limitprivs);
! 644: #endif /* HAVE_PRIV_SET */
1.1 misho 645: if (cs->tags.nopasswd != UNSPEC && cs->tags.nopasswd != tags.nopasswd)
646: printf("%sPASSWD: ", cs->tags.nopasswd ? "NO" : "");
647: if (cs->tags.noexec != UNSPEC && cs->tags.noexec != tags.noexec)
648: printf("%sEXEC: ", cs->tags.noexec ? "NO" : "");
649: print_member(cs->cmnd);
650: memcpy(&tags, &cs->tags, sizeof(tags));
651: }
652: }
1.1.1.2 misho 653: debug_return;
1.1 misho 654: }
655:
656: void
657: print_userspecs(void)
658: {
659: struct member *m;
660: struct userspec *us;
1.1.1.2 misho 661: debug_decl(print_userspecs, SUDO_DEBUG_UTIL)
1.1 misho 662:
663: tq_foreach_fwd(&userspecs, us) {
664: tq_foreach_fwd(&us->users, m) {
665: if (m != tq_first(&us->users))
666: fputs(", ", stdout);
667: print_member(m);
668: }
669: putchar('\t');
670: print_privilege(us->privileges.first); /* XXX */
671: putchar('\n');
672: }
1.1.1.2 misho 673: debug_return;
1.1 misho 674: }
675:
676: static int
677: testsudoers_printf(int msg_type, const char *fmt, ...)
678: {
679: va_list ap;
680: FILE *fp;
1.1.1.2 misho 681: debug_decl(testsudoers_printf, SUDO_DEBUG_UTIL)
1.1 misho 682:
683: switch (msg_type) {
684: case SUDO_CONV_INFO_MSG:
685: fp = stdout;
686: break;
687: case SUDO_CONV_ERROR_MSG:
688: fp = stderr;
689: break;
690: default:
691: errno = EINVAL;
1.1.1.2 misho 692: debug_return_int(-1);
1.1 misho 693: }
694:
695: va_start(ap, fmt);
696: vfprintf(fp, fmt, ap);
697: va_end(ap);
698:
1.1.1.2 misho 699: debug_return_int(0);
1.1 misho 700: }
701:
702: void
703: dump_sudoers(void)
704: {
1.1.1.2 misho 705: debug_decl(dump_sudoers, SUDO_DEBUG_UTIL)
706:
1.1 misho 707: print_defaults();
708:
709: putchar('\n');
710: alias_apply(print_alias, NULL);
711:
712: putchar('\n');
713: print_userspecs();
1.1.1.2 misho 714:
715: debug_return;
1.1 misho 716: }
717:
718: static int testsudoers_print(const char *msg)
719: {
720: return fputs(msg, stderr);
721: }
722:
723: void
724: usage(void)
725: {
1.1.1.3 ! misho 726: (void) fprintf(stderr, "usage: %s [-dt] [-G sudoers_gid] [-g group] [-h host] [-p grfile] [-p pwfile] [-U sudoers_uid] [-u user] <user> <command> [args]\n", getprogname());
1.1 misho 727: exit(1);
728: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>