diff options
author | Andrew Tridgell <tridge@samba.org> | 1999-07-14 12:19:13 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1999-07-14 12:19:13 +0000 |
commit | c9954ef686a9e47240498f63918705b9b35d38bc (patch) | |
tree | 774e8dccf089530d03c6b9bd14a47bc7c80a37be | |
parent | c1f0ecfcf98313b3769b6630843d02c8c67d24cc (diff) | |
download | samba-c9954ef686a9e47240498f63918705b9b35d38bc.tar.gz |
pid_t and testparm cleanups from the 2.0 branch
-rw-r--r-- | source/utils/status.c | 25 | ||||
-rw-r--r-- | source/utils/testparm.c | 144 |
2 files changed, 101 insertions, 68 deletions
diff --git a/source/utils/status.c b/source/utils/status.c index 96df0878581..ec3605323f7 100644 --- a/source/utils/status.c +++ b/source/utils/status.c @@ -39,8 +39,8 @@ struct connect_record crec; struct session_record{ - int pid; - int uid; + pid_t pid; + uid_t uid; char machine[31]; time_t start; struct session_record *next; @@ -51,7 +51,7 @@ extern FILE *dbf; extern pstring myhostname; static pstring Ucrit_username = ""; /* added by OH */ -int Ucrit_pid[100]; /* Ugly !!! */ /* added by OH */ +pid_t Ucrit_pid[100]; /* Ugly !!! */ /* added by OH */ int Ucrit_MaxPid=0; /* added by OH */ unsigned int Ucrit_IsActive = 0; /* added by OH */ @@ -78,7 +78,7 @@ static unsigned int Ucrit_checkUsername(char *username) return 0; } -static void Ucrit_addPid(int pid) +static void Ucrit_addPid(pid_t pid) { int i; if ( !Ucrit_IsActive) return; @@ -87,7 +87,7 @@ static void Ucrit_addPid(int pid) Ucrit_pid[Ucrit_MaxPid++] = pid; } -static unsigned int Ucrit_checkPid(int pid) +static unsigned int Ucrit_checkPid(pid_t pid) { int i; if ( !Ucrit_IsActive) return 1; @@ -108,7 +108,7 @@ static void print_share_mode(share_mode_entry *e, char *fname) count++; if (Ucrit_checkPid(e->pid)) { - printf("%-5d ",e->pid); + printf("%-5d ",(int)e->pid); switch ((e->share_mode>>4)&0xF) { case DENY_NONE: printf("DENY_NONE "); break; case DENY_ALL: printf("DENY_ALL "); break; @@ -130,10 +130,13 @@ static void print_share_mode(share_mode_entry *e, char *fname) printf("EXCLUSIVE "); else if (e->op_type & BATCH_OPLOCK) printf("BATCH "); + else if (e->op_type & LEVEL_II_OPLOCK) + printf("LEVEL_II "); else printf("NONE "); - printf(" %s %s",fname,asctime(LocalTime((time_t *)&e->time.tv_sec))); + printf(" %s %s",dos_to_unix(fname,False), + asctime(LocalTime((time_t *)&e->time.tv_sec))); } } @@ -148,7 +151,7 @@ static void print_share_mode(share_mode_entry *e, char *fname) extern char *optarg; int verbose = 0, brief =0; BOOL processes_only=False; - int last_pid=0; + pid_t last_pid=(pid_t)0; struct session_record *ptr; @@ -278,13 +281,13 @@ static void print_share_mode(share_mode_entry *e, char *fname) Ucrit_addPid(crec.pid); /* added by OH */ if (processes_only) { if (last_pid != crec.pid) - printf("%d\n",crec.pid); + printf("%d\n",(int)crec.pid); last_pid = crec.pid; /* XXXX we can still get repeats, have to add a sort at some time */ } else printf("%-10.10s %-8s %-8s %5d %-8s (%s) %s", - crec.name,uidtoname(crec.uid),gidtoname(crec.gid),crec.pid, + crec.name,uidtoname(crec.uid),gidtoname(crec.gid),(int)crec.pid, crec.machine,crec.addr, asctime(LocalTime(&crec.start))); } @@ -299,7 +302,7 @@ static void print_share_mode(share_mode_entry *e, char *fname) ptr=srecs; while (ptr!=NULL) { - printf("%-8d%-10.10s%-30.30s%s",ptr->pid,uidtoname(ptr->uid),ptr->machine,asctime(LocalTime(&(ptr->start)))); + printf("%-8d%-10.10s%-30.30s%s",(int)ptr->pid,uidtoname(ptr->uid),ptr->machine,asctime(LocalTime(&(ptr->start)))); ptr=ptr->next; } printf("\n"); diff --git a/source/utils/testparm.c b/source/utils/testparm.c index 7baeecd80b3..7406759a759 100644 --- a/source/utils/testparm.c +++ b/source/utils/testparm.c @@ -146,10 +146,24 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_ return ret; } +static void usage(char *pname) +{ + printf("Usage: %s [-sh] [-L servername] [configfilename] [hostname hostIP]\n", pname); + printf("\t-s Suppress prompt for enter\n"); + printf("\t-h Print usage\n"); + printf("\t-L servername Set %%L macro to servername\n"); + printf("\tconfigfilename Configuration file to test\n"); + printf("\thostname hostIP. Hostname and Host IP address to test\n"); + printf("\t against \"host allow\" and \"host deny\"\n"); + printf("\n"); +} + + int main(int argc, char *argv[]) { extern char *optarg; extern int optind; + extern fstring local_machine; pstring configfile; int opt; int s; @@ -162,11 +176,23 @@ int main(int argc, char *argv[]) charset_initialise(); - while ((opt = getopt(argc, argv,"s")) != EOF) { + while ((opt = getopt(argc, argv,"shL:")) != EOF) { switch (opt) { case 's': silent_mode = True; break; + case 'L': + fstrcpy(local_machine,optarg); + break; + case 'h': + usage(argv[0]); + exit(0); + break; + default: + printf("Incorrect program usage\n"); + usage(argv[0]); + exit(1); + break; } } @@ -196,74 +222,78 @@ int main(int argc, char *argv[]) ret = do_global_checks(); - for (s=0;s<1000;s++) + for (s=0;s<1000;s++) { if (VALID_SNUM(s)) if (strlen(lp_servicename(s)) > 8) { - printf("WARNING: You have some share names that are longer than 8 chars\n"); - printf("These may give errors while browsing or may not be accessible\nto some older clients\n"); - break; + printf("WARNING: You have some share names that are longer than 8 chars\n"); + printf("These may give errors while browsing or may not be accessible\nto some older clients\n"); + break; } + } - for (s=0;s<1000;s++) { - if (VALID_SNUM(s)) { - char *deny_list = lp_hostsdeny(s); - char *allow_list = lp_hostsallow(s); - if(deny_list) { - char *hasstar = strchr(deny_list, '*'); - char *hasquery = strchr(deny_list, '?'); - if(hasstar || hasquery) { - printf("Invalid character %c in hosts deny list %s for service %s.\n", - hasstar ? *hasstar : *hasquery, deny_list, lp_servicename(s) ); - } - } + for (s=0;s<1000;s++) { + if (VALID_SNUM(s)) { + char *deny_list = lp_hostsdeny(s); + char *allow_list = lp_hostsallow(s); + if(deny_list) { + char *hasstar = strchr(deny_list, '*'); + char *hasquery = strchr(deny_list, '?'); + if(hasstar || hasquery) { + printf("Invalid character %c in hosts deny list %s for service %s.\n", + hasstar ? *hasstar : *hasquery, deny_list, lp_servicename(s) ); + } + } - if(allow_list) { - char *hasstar = strchr(allow_list, '*'); - char *hasquery = strchr(allow_list, '?'); - if(hasstar || hasquery) { - printf("Invalid character %c in hosts allow list %s for service %s.\n", - hasstar ? *hasstar : *hasquery, allow_list, lp_servicename(s) ); - } - } - } - } + if(allow_list) { + char *hasstar = strchr(allow_list, '*'); + char *hasquery = strchr(allow_list, '?'); + if(hasstar || hasquery) { + printf("Invalid character %c in hosts allow list %s for service %s.\n", + hasstar ? *hasstar : *hasquery, allow_list, lp_servicename(s) ); + } + } - if (argc < 3) { - if (!silent_mode) { - printf("Press enter to see a dump of your service definitions\n"); - fflush(stdout); - getc(stdin); + if(lp_level2_oplocks(s) && !lp_oplocks(s)) { + printf("Invalid combination of parameters for service %s. \ +Level II oplocks can only be set if oplocks are also set.\n", + lp_servicename(s) ); } - lp_dump(stdout,True, lp_numservices()); + } + } + + if (argc < 3) { + if (!silent_mode) { + printf("Press enter to see a dump of your service definitions\n"); + fflush(stdout); + getc(stdin); + } + lp_dump(stdout,True, lp_numservices()); } if (argc >= 3) { - char *cname=NULL; - char *caddr=NULL; + char *cname; + char *caddr; - if (argc == 3) { - cname = argv[optind]; - caddr = argv[optind+1]; - } else if (argc == 4) { - cname = argv[optind+1]; - caddr = argv[optind+2]; - } + if (argc == 3) { + cname = argv[optind]; + caddr = argv[optind+1]; + } else if (argc == 4) { + cname = argv[optind+1]; + caddr = argv[optind+2]; + } - /* this is totally ugly, a real `quick' hack */ - for (s=0;s<1000;s++) - if (VALID_SNUM(s)) { - if (allow_access(lp_hostsdeny(s),lp_hostsallow(s),cname,caddr)) { - printf("Allow connection from %s (%s) to %s\n", - cname,caddr,lp_servicename(s)); - } - else - { - printf("Deny connection from %s (%s) to %s\n", - cname,caddr,lp_servicename(s)); - } - } + /* this is totally ugly, a real `quick' hack */ + for (s=0;s<1000;s++) { + if (VALID_SNUM(s)) { + if (allow_access(lp_hostsdeny(s),lp_hostsallow(s),cname,caddr)) { + printf("Allow connection from %s (%s) to %s\n", + cname,caddr,lp_servicename(s)); + } else { + printf("Deny connection from %s (%s) to %s\n", + cname,caddr,lp_servicename(s)); + } + } } + } return(ret); } - - |