static struct loadparm_service *lp_service_for_s4_ctx(const char *servicename) { TALLOC_CTX *mem_ctx; struct loadparm_service *service; mem_ctx = talloc_stackframe(); service = lp_service(servicename); talloc_free(mem_ctx); return service; }
static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, const char *caddr, bool silent_mode, bool show_defaults, const char *section_name, const char *parameter_name) { int ret = 0; int s; for (s=0;s<lp_numservices(lp_ctx);s++) { struct loadparm_service *service = lp_servicebynum(lp_ctx, s); if (service != NULL) if (strlen(lp_servicename(lp_servicebynum(lp_ctx, s))) > 12) { fprintf(stderr, "WARNING: You have some share names that are longer than 12 characters.\n" ); fprintf(stderr, "These may not be accessible to some older clients.\n" ); fprintf(stderr, "(Eg. Windows9x, WindowsMe, and not listed in smbclient in Samba 3.0.)\n" ); break; } } for (s=0;s<lp_numservices(lp_ctx);s++) { struct loadparm_service *service = lp_servicebynum(lp_ctx, s); if (service != NULL) { const char **deny_list = lp_hostsdeny(service, lp_default_service(lp_ctx)); const char **allow_list = lp_hostsallow(service, lp_default_service(lp_ctx)); int i; if(deny_list) { for (i=0; deny_list[i]; i++) { char *hasstar = strchr_m(deny_list[i], '*'); char *hasquery = strchr_m(deny_list[i], '?'); if(hasstar || hasquery) { fprintf(stderr,"Invalid character %c in hosts deny list (%s) for service %s.\n", hasstar ? *hasstar : *hasquery, deny_list[i], lp_servicename(service) ); } } } if(allow_list) { for (i=0; allow_list[i]; i++) { char *hasstar = strchr_m(allow_list[i], '*'); char *hasquery = strchr_m(allow_list[i], '?'); if(hasstar || hasquery) { fprintf(stderr,"Invalid character %c in hosts allow list (%s) for service %s.\n", hasstar ? *hasstar : *hasquery, allow_list[i], lp_servicename(service) ); } } } } } if (!cname) { if (!silent_mode) { fprintf(stderr,"Press enter to see a dump of your service definitions\n"); fflush(stdout); getc(stdin); } if (section_name != NULL || parameter_name != NULL) { struct loadparm_service *service = NULL; if (!section_name) { section_name = GLOBAL_NAME; service = NULL; } else if ((!strwicmp(section_name, GLOBAL_NAME)) == 0 && (service=lp_service(lp_ctx, section_name)) == NULL) { fprintf(stderr,"Unknown section %s\n", section_name); return(1); } if (!parameter_name) { lp_dump_one(stdout, show_defaults, service, lp_default_service(lp_ctx)); } else { ret = !lp_dump_a_parameter(lp_ctx, service, parameter_name, stdout); } } else { lp_dump(lp_ctx, stdout, show_defaults, lp_numservices(lp_ctx)); } return(ret); } if(cname && caddr){ /* this is totally ugly, a real `quick' hack */ for (s=0;s<lp_numservices(lp_ctx);s++) { struct loadparm_service *service = lp_servicebynum(lp_ctx, s); if (service != NULL) { if (allow_access(NULL, lp_hostsdeny(NULL, lp_default_service(lp_ctx)), lp_hostsallow(NULL, lp_default_service(lp_ctx)), cname, caddr) && allow_access(NULL, lp_hostsdeny(service, lp_default_service(lp_ctx)), lp_hostsallow(service, lp_default_service(lp_ctx)), cname, caddr)) { fprintf(stderr,"Allow connection from %s (%s) to %s\n", cname,caddr,lp_servicename(service)); } else { fprintf(stderr,"Deny connection from %s (%s) to %s\n", cname,caddr,lp_servicename(service)); } } } } return ret; }