File:  [MW Coherent from dump] / coherent / d / bin / uucheck / checkperms / parse_args.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:39 2019 UTC (7 years, 2 months ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/* parse_args - parse arguments to uucheck.
 * Possible arguments are:
 * -s or -silent	no output
 * -v or -verbose	verbose output
 * -f or -fix		fix as much as possible, must be root to use
 */

#include "checkperms.h"

void
parse_args(argc, argv)
	int argc;
	char *argv[];
{
	int i;

	silent = FALSE;	 /* Generate no output if set.  Overrides verbose.  */
	verbose = FALSE; /* Generate verbose output if set.  */
	reallyverbose = FALSE; /* Generate really verbose output if set.  */
	fix = FALSE;	 /* Attempt to fix problems if set.  */

	do_sitename = TRUE;
	do_lockfiles = TRUE;
	do_fileperms = TRUE;
	do_devices = TRUE;
	do_sys = TRUE;
	do_permissions = TRUE;
	do_log = TRUE;
	
	for (i = 1; i < argc; ++i) {
		if ( (strcmp(argv[i], "-s") == 0) ||
		     (strcmp(argv[i], "-silent") == 0) ){
			silent = TRUE;
			continue;
		} /* if argv[i] == -silent */

		if ( (strcmp(argv[i], "-v") == 0) ||
		     (strcmp(argv[i], "-verbose") == 0) ){
			if(verbose) {
				reallyverbose = TRUE;
			} else {
				verbose = TRUE;
			} /* if already verbose */
			continue;
		} /* if argv[i] == -verbose */

		if ( (strcmp(argv[i], "-f") == 0) ||
		     (strcmp(argv[i], "-fix") == 0) ){
			if(getuid() == 0) {
				fix = TRUE;
			} else {
				fprintf(stderr, "Only root can fix.\n");
			} /* if I'm root */
			continue;
		} /* if argv[i] == -fix */

		fprintf(stderr, USAGE);
		exit(255);
	} /* for i = 1 to argc */


} /* parse_args() */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.