Go to the source code of this file.
Data Structures | |
struct | enum_list |
struct | parm_struct |
struct | global |
struct | service |
Typedefs | |
typedef char | pstring [1024] |
Enumerations | |
enum | parm_type { P_BOOL, P_BOOLREV, P_CHAR, P_INTEGER, P_OCTAL, P_STRING, P_GSTRING, P_ENUM, P_SEP } |
enum | parm_class { P_LOCAL, P_GLOBAL, P_SEPARATOR, P_NONE } |
Functions | |
void | init_globals (void) |
void | init_locals (void) |
FN_GLOBAL_STRING (lp_motd_file,&Globals.motd_file) FN_GLOBAL_STRING(lp_log_file | |
&Globals log_file &Globals socket_options | FN_GLOBAL_INTEGER (lp_syslog_facility,&Globals.syslog_facility) FN_LOCAL_STRING(lp_name |
&Globals log_file &Globals socket_options name | FN_LOCAL_STRING (lp_comment, comment) FN_LOCAL_STRING(lp_path |
&Globals log_file &Globals socket_options name path | FN_LOCAL_STRING (lp_lock_file, lock_file) FN_LOCAL_BOOL(lp_read_only |
&Globals log_file &Globals socket_options name path read_only | FN_LOCAL_BOOL (lp_list, list) FN_LOCAL_BOOL(lp_use_chroot |
&Globals log_file &Globals socket_options name path read_only use_chroot | FN_LOCAL_BOOL (lp_transfer_logging, transfer_logging) FN_LOCAL_BOOL(lp_ignore_errors |
&Globals log_file &Globals socket_options name path read_only use_chroot ignore_errors | FN_LOCAL_BOOL (lp_ignore_nonreadable, ignore_nonreadable) FN_LOCAL_STRING(lp_uid |
&Globals log_file &Globals socket_options name path read_only use_chroot ignore_errors uid | FN_LOCAL_STRING (lp_gid, gid) FN_LOCAL_STRING(lp_hosts_allow |
&Globals log_file &Globals socket_options name path read_only use_chroot ignore_errors uid hosts_allow | FN_LOCAL_STRING (lp_hosts_deny, hosts_deny) FN_LOCAL_STRING(lp_auth_users |
&Globals log_file &Globals socket_options name path read_only use_chroot ignore_errors uid hosts_allow auth_users | FN_LOCAL_STRING (lp_secrets_file, secrets_file) FN_LOCAL_BOOL(lp_strict_modes |
&Globals log_file &Globals socket_options name path read_only use_chroot ignore_errors uid hosts_allow auth_users strict_modes | FN_LOCAL_STRING (lp_exclude, exclude) FN_LOCAL_STRING(lp_exclude_from |
&Globals log_file &Globals socket_options name path read_only use_chroot ignore_errors uid hosts_allow auth_users strict_modes exclude_from | FN_LOCAL_STRING (lp_include, include) FN_LOCAL_STRING(lp_include_from |
&Globals log_file &Globals socket_options name path read_only use_chroot ignore_errors uid hosts_allow auth_users strict_modes exclude_from include_from refuse_options | FN_LOCAL_STRING (lp_dont_compress, dont_compress) FN_LOCAL_INTEGER(lp_timeout |
&Globals log_file &Globals socket_options name path read_only use_chroot ignore_errors uid hosts_allow auth_users strict_modes exclude_from include_from refuse_options timeout | FN_LOCAL_INTEGER (lp_max_connections, max_connections) static int strwicmp(char *psz1 |
int | map_parameter (char *parmname) |
BOOL | set_boolean (BOOL *pb, char *parmvalue) |
int | getservicebyname (char *name, service *pserviceDest) |
void | copy_service (service *pserviceDest, service *pserviceSource) |
BOOL | do_parameter (char *parmname, char *parmvalue) |
BOOL | do_section (char *sectionname) |
void | init_service (service *pservice) |
void | string_set (char **s, const char *v) |
Assign a copy of v to *s . More... | |
int | add_a_service (service *pservice, char *name) |
int | strwicmp (char *psz1, char *psz2) |
BOOL | lp_do_parameter (int snum, char *parmname, char *parmvalue) |
BOOL | lp_load (char *pszFname, int globals_only) |
int | lp_numservices (void) |
int | lp_number (char *name) |
Variables | |
global | Globals |
service | sDefault |
service ** | ServicePtrs = NULL |
int | iNumServices = 0 |
int | iServiceIndex = 0 |
BOOL | bInGlobalSection = True |
enum_list | enum_facilities [] |
parm_struct | parm_table [] |
&Globals log_file &Globals socket_options name path read_only use_chroot ignore_errors uid hosts_allow auth_users strict_modes exclude_from include_from refuse_options timeout char * | psz2 |
|
Definition at line 57 of file loadparm.c. Referenced by lp_do_parameter(), and lp_load(). |
|
Definition at line 61 of file loadparm.c.
|
|
Definition at line 67 of file loadparm.c.
00068 { 00069 P_LOCAL,P_GLOBAL,P_SEPARATOR,P_NONE 00070 } parm_class; |
|
Definition at line 305 of file loadparm.c. References global::syslog_facility. Referenced by lp_load().
00306 { 00307 memset(&Globals, 0, sizeof(Globals)); 00308 #ifdef LOG_DAEMON 00309 Globals.syslog_facility = LOG_DAEMON; 00310 #endif 00311 } |
|
Definition at line 316 of file loadparm.c. Referenced by do_section().
00317 { 00318 } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 499 of file loadparm.c. References FERROR, parm_struct::label, rprintf(), and strwicmp(). Referenced by lp_do_parameter().
00500 { 00501 int iIndex; 00502 00503 if (*parmname == '-') 00504 return(-1); 00505 00506 for (iIndex = 0; parm_table[iIndex].label; iIndex++) 00507 if (strwicmp(parm_table[iIndex].label, parmname) == 0) 00508 return(iIndex); 00509 00510 rprintf(FERROR, "Unknown Parameter encountered: \"%s\"\n", parmname); 00511 return(-1); 00512 } |
|
Definition at line 520 of file loadparm.c. References FERROR, rprintf(), and strwicmp(). Referenced by lp_do_parameter().
00521 { 00522 BOOL bRetval; 00523 00524 bRetval = True; 00525 if (strwicmp(parmvalue, "yes") == 0 || 00526 strwicmp(parmvalue, "true") == 0 || 00527 strwicmp(parmvalue, "1") == 0) 00528 *pb = True; 00529 else 00530 if (strwicmp(parmvalue, "no") == 0 || 00531 strwicmp(parmvalue, "False") == 0 || 00532 strwicmp(parmvalue, "0") == 0) 00533 *pb = False; 00534 else 00535 { 00536 rprintf(FERROR, "Badly formed boolean in configuration file: \"%s\".\n", 00537 parmvalue); 00538 bRetval = False; 00539 } 00540 return (bRetval); 00541 } |
|
Definition at line 546 of file loadparm.c. References copy_service(), iNumServices, and strwicmp(). Referenced by add_a_service().
00547 { 00548 int iService; 00549 00550 for (iService = iNumServices - 1; iService >= 0; iService--) 00551 if (strwicmp(iSERVICE(iService).name, name) == 0) 00552 { 00553 if (pserviceDest != NULL) 00554 copy_service(pserviceDest, pSERVICE(iService)); 00555 break; 00556 } 00557 00558 return (iService); 00559 } |
|
Definition at line 567 of file loadparm.c. References parm_struct::class, parm_struct::label, P_BOOL, P_BOOLREV, P_CHAR, P_ENUM, P_INTEGER, P_LOCAL, P_OCTAL, P_STRING, parm_struct::ptr, string_set(), and parm_struct::type. Referenced by add_a_service(), getservicebyname(), and init_service().
00569 { 00570 int i; 00571 00572 for (i=0;parm_table[i].label;i++) 00573 if (parm_table[i].ptr && parm_table[i].class == P_LOCAL) { 00574 void *def_ptr = parm_table[i].ptr; 00575 void *src_ptr = 00576 ((char *)pserviceSource) + PTR_DIFF(def_ptr,&sDefault); 00577 void *dest_ptr = 00578 ((char *)pserviceDest) + PTR_DIFF(def_ptr,&sDefault); 00579 00580 switch (parm_table[i].type) 00581 { 00582 case P_BOOL: 00583 case P_BOOLREV: 00584 *(BOOL *)dest_ptr = *(BOOL *)src_ptr; 00585 break; 00586 00587 case P_INTEGER: 00588 case P_ENUM: 00589 case P_OCTAL: 00590 *(int *)dest_ptr = *(int *)src_ptr; 00591 break; 00592 00593 case P_CHAR: 00594 *(char *)dest_ptr = *(char *)src_ptr; 00595 break; 00596 00597 case P_STRING: 00598 string_set(dest_ptr,*(char **)src_ptr); 00599 break; 00600 00601 default: 00602 break; 00603 } 00604 } 00605 } |
|
Definition at line 693 of file loadparm.c. References bInGlobalSection, iServiceIndex, and lp_do_parameter(). Referenced by lp_load().
00694 { 00695 return lp_do_parameter(bInGlobalSection?-2:iServiceIndex, parmname, parmvalue); 00696 } |
|
Definition at line 703 of file loadparm.c. References add_a_service(), bInGlobalSection, FERROR, init_locals(), iServiceIndex, rprintf(), and strwicmp().
00704 { 00705 BOOL bRetval; 00706 BOOL isglobal = (strwicmp(sectionname, GLOBAL_NAME) == 0); 00707 bRetval = False; 00708 00709 /* if we were in a global section then do the local inits */ 00710 if (bInGlobalSection && !isglobal) 00711 init_locals(); 00712 00713 /* if we've just struck a global section, note the fact. */ 00714 bInGlobalSection = isglobal; 00715 00716 /* check for multiple global sections */ 00717 if (bInGlobalSection) 00718 { 00719 return(True); 00720 } 00721 00722 /* if we have a current service, tidy it up before moving on */ 00723 bRetval = True; 00724 00725 if (iServiceIndex >= 0) 00726 bRetval = True; 00727 00728 /* if all is still well, move to the next record in the services array */ 00729 if (bRetval) 00730 { 00731 /* We put this here to avoid an odd message order if messages are */ 00732 /* issued by the post-processing of a previous section. */ 00733 00734 if ((iServiceIndex=add_a_service(&sDefault,sectionname)) < 0) 00735 { 00736 rprintf(FERROR,"Failed to add a new service\n"); 00737 return(False); 00738 } 00739 } 00740 00741 return (bRetval); 00742 } |
|
Definition at line 392 of file loadparm.c. References copy_service(). Referenced by add_a_service().
00393 { 00394 memset((char *)pservice,0,sizeof(service)); 00395 copy_service(pservice,&sDefault); 00396 } |
|
Assign a copy of
Handles NULL strings. @fixme There is a small leak here in that sometimes the existing value will be dynamically allocated, and the old copy is lost. However, we can't always deallocate the old value, because in the case of sDefault, it points to a static string. It would be nice to have either all-strdup'd values, or to never need to free memory. Definition at line 411 of file loadparm.c. References strdup(). Referenced by add_a_service(), copy_service(), and lp_do_parameter().
00412 { 00413 if (!v) { 00414 *s = NULL; 00415 return; 00416 } 00417 *s = strdup(v); 00418 if (!*s) 00419 exit_cleanup(RERR_MALLOC); 00420 } |
|
Definition at line 427 of file loadparm.c. References copy_service(), getservicebyname(), init_service(), iNumServices, Realloc(), and string_set(). Referenced by do_section().
00428 { 00429 int i; 00430 service tservice; 00431 int num_to_alloc = iNumServices+1; 00432 00433 tservice = *pservice; 00434 00435 /* it might already exist */ 00436 if (name) 00437 { 00438 i = getservicebyname(name,NULL); 00439 if (i >= 0) 00440 return(i); 00441 } 00442 00443 i = iNumServices; 00444 00445 ServicePtrs = (service **)Realloc(ServicePtrs,sizeof(service *)*num_to_alloc); 00446 00447 if (ServicePtrs) 00448 pSERVICE(iNumServices) = (service *)malloc(sizeof(service)); 00449 00450 if (!ServicePtrs || !pSERVICE(iNumServices)) 00451 return(-1); 00452 00453 iNumServices++; 00454 00455 init_service(pSERVICE(i)); 00456 copy_service(pSERVICE(i),&tservice); 00457 if (name) 00458 string_set(&iSERVICE(i).name,name); 00459 00460 return(i); 00461 } |
|
Definition at line 466 of file loadparm.c. References psz2. Referenced by do_section(), getservicebyname(), map_parameter(), and set_boolean().
00467 { 00468 /* if BOTH strings are NULL, return TRUE, if ONE is NULL return */ 00469 /* appropriate value. */ 00470 if (psz1 == psz2) 00471 return (0); 00472 else 00473 if (psz1 == NULL) 00474 return (-1); 00475 else 00476 if (psz2 == NULL) 00477 return (1); 00478 00479 /* sync the strings on first non-whitespace */ 00480 while (1) 00481 { 00482 while (isspace(* (unsigned char *) psz1)) 00483 psz1++; 00484 while (isspace(* (unsigned char *) psz2)) 00485 psz2++; 00486 if (toupper(* (unsigned char *) psz1) != toupper(* (unsigned char *) psz2) 00487 || *psz1 == '\0' || *psz2 == '\0') 00488 break; 00489 psz1++; 00490 psz2++; 00491 } 00492 return (*psz1 - *psz2); 00493 } |
|
Definition at line 612 of file loadparm.c. References parm_struct::class, parm_struct::enum_list, FERROR, map_parameter(), enum_list::name, P_BOOL, P_BOOLREV, P_CHAR, P_ENUM, P_GLOBAL, P_GSTRING, P_INTEGER, P_OCTAL, P_SEP, P_STRING, pstring, parm_struct::ptr, rprintf(), set_boolean(), string_set(), strlcpy(), parm_struct::type, and enum_list::value. Referenced by do_parameter().
00613 { 00614 int parmnum, i; 00615 void *parm_ptr=NULL; /* where we are going to store the result */ 00616 void *def_ptr=NULL; 00617 00618 parmnum = map_parameter(parmname); 00619 00620 if (parmnum < 0) 00621 { 00622 rprintf(FERROR, "IGNORING unknown parameter \"%s\"\n", parmname); 00623 return(True); 00624 } 00625 00626 def_ptr = parm_table[parmnum].ptr; 00627 00628 /* we might point at a service, the default service or a global */ 00629 if (snum < 0) { 00630 parm_ptr = def_ptr; 00631 } else { 00632 if (parm_table[parmnum].class == P_GLOBAL) { 00633 rprintf(FERROR, "Global parameter %s found in service section!\n",parmname); 00634 return(True); 00635 } 00636 parm_ptr = ((char *)pSERVICE(snum)) + PTR_DIFF(def_ptr,&sDefault); 00637 } 00638 00639 /* now switch on the type of variable it is */ 00640 switch (parm_table[parmnum].type) 00641 { 00642 case P_BOOL: 00643 set_boolean(parm_ptr,parmvalue); 00644 break; 00645 00646 case P_BOOLREV: 00647 set_boolean(parm_ptr,parmvalue); 00648 *(BOOL *)parm_ptr = ! *(BOOL *)parm_ptr; 00649 break; 00650 00651 case P_INTEGER: 00652 *(int *)parm_ptr = atoi(parmvalue); 00653 break; 00654 00655 case P_CHAR: 00656 *(char *)parm_ptr = *parmvalue; 00657 break; 00658 00659 case P_OCTAL: 00660 sscanf(parmvalue,"%o",(int *)parm_ptr); 00661 break; 00662 00663 case P_STRING: 00664 string_set(parm_ptr,parmvalue); 00665 break; 00666 00667 case P_GSTRING: 00668 strlcpy((char *)parm_ptr,parmvalue,sizeof(pstring)); 00669 break; 00670 00671 case P_ENUM: 00672 for (i=0;parm_table[parmnum].enum_list[i].name;i++) { 00673 if (strequal(parmvalue, parm_table[parmnum].enum_list[i].name)) { 00674 *(int *)parm_ptr = parm_table[parmnum].enum_list[i].value; 00675 break; 00676 } 00677 } 00678 if (!parm_table[parmnum].enum_list[i].name) { 00679 if (atoi(parmvalue) > 0) 00680 *(int *)parm_ptr = atoi(parmvalue); 00681 } 00682 break; 00683 case P_SEP: 00684 break; 00685 } 00686 00687 return(True); 00688 } |
|
Definition at line 749 of file loadparm.c. References bInGlobalSection, do_parameter(), init_globals(), iServiceIndex, pm_process(), and pstring. Referenced by daemon_main(), and start_daemon().
00750 { 00751 pstring n2; 00752 BOOL bRetval; 00753 00754 bRetval = False; 00755 00756 bInGlobalSection = True; 00757 00758 init_globals(); 00759 00760 pstrcpy(n2,pszFname); 00761 00762 /* We get sections first, so have to start 'behind' to make up */ 00763 iServiceIndex = -1; 00764 bRetval = pm_process(n2, globals_only?NULL:do_section, do_parameter); 00765 00766 return (bRetval); 00767 } |
|
Definition at line 773 of file loadparm.c. Referenced by send_listing().
00774 { 00775 return(iNumServices); 00776 } |
|
Definition at line 784 of file loadparm.c. References iNumServices. Referenced by start_daemon().
00785 { 00786 int iService; 00787 00788 for (iService = iNumServices - 1; iService >= 0; iService--) 00789 if (strequal(lp_name(iService), name)) 00790 break; 00791 00792 return (iService); 00793 } |
|
Definition at line 108 of file loadparm.c. |
|
Definition at line 147 of file loadparm.c. |
|
Definition at line 189 of file loadparm.c. |
|
Definition at line 190 of file loadparm.c. Referenced by add_a_service(), getservicebyname(), and lp_number(). |
|
Definition at line 191 of file loadparm.c. Referenced by do_parameter(), do_section(), and lp_load(). |
|
Definition at line 192 of file loadparm.c. Referenced by do_parameter(), do_section(), and lp_load(). |
|
Definition at line 196 of file loadparm.c. |
|
Definition at line 264 of file loadparm.c. |
|
Definition at line 379 of file loadparm.c. Referenced by strwicmp(). |