diff options
author | Gerald Carter <jerry@samba.org> | 2002-05-09 04:08:00 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2002-05-09 04:08:00 +0000 |
commit | 4db4e95ab2140e179d0f15ad390b7a994b6642f2 (patch) | |
tree | 7c5829c3a3d11860fc164b9f0aa7c593eb4d0a62 /source3/lib/util.c | |
parent | 9ac3ca512a4d6a99848c708d1b83adcb0d452b59 (diff) | |
download | samba-4db4e95ab2140e179d0f15ad390b7a994b6642f2.tar.gz samba-4db4e95ab2140e179d0f15ad390b7a994b6642f2.tar.xz samba-4db4e95ab2140e179d0f15ad390b7a994b6642f2.zip |
pidfile merge from SAMBA_2_2 (including --with-fhs) and a few other minor things; compiles and shouldnt break, but needs testing
(This used to be commit 19b9b50d9039afe614284aaf379f9f1078e2e307)
Diffstat (limited to 'source3/lib/util.c')
-rw-r--r-- | source3/lib/util.c | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index dcb42bbfc4..5f80fa6757 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -91,9 +91,10 @@ char **my_netbios_names; /**************************************************************************** - find a suitable temporary directory. The result should be copied immediately + Find a suitable temporary directory. The result should be copied immediately as it may be overwritten by a subsequent call. - ****************************************************************************/ +****************************************************************************/ + char *tmpdir(void) { char *p; @@ -190,7 +191,7 @@ BOOL file_exist(const char *fname,SMB_STRUCT_STAT *sbuf) if (sys_stat(fname,sbuf) != 0) return(False); - return(S_ISREG(sbuf->st_mode)); + return((S_ISREG(sbuf->st_mode)) || (S_ISFIFO(sbuf->st_mode))); } /******************************************************************* @@ -689,7 +690,7 @@ void become_daemon(void) /**************************************************************************** -put up a yes/no prompt + Put up a yes/no prompt ****************************************************************************/ BOOL yesno(char *p) { @@ -862,7 +863,7 @@ struct in_addr *interpret_addr2(const char *str) } /******************************************************************* - check if an IP is the 0.0.0.0 + Check if an IP is the 0.0.0.0 ******************************************************************/ BOOL is_zero_ip(struct in_addr ip) { @@ -871,7 +872,9 @@ BOOL is_zero_ip(struct in_addr ip) return(a == 0); } -/* Set an IP to 0.0.0.0 */ +/******************************************************************* + Set an IP to 0.0.0.0 + ******************************************************************/ void zero_ip(struct in_addr *ip) { @@ -1062,7 +1065,8 @@ char *uidtoname(uid_t uid) struct passwd *pass; pass = sys_getpwuid(uid); - if (pass) return(pass->pw_name); + if (pass) + return(pass->pw_name); slprintf(name, sizeof(name) - 1, "%d",(int)uid); return(name); } @@ -1078,7 +1082,8 @@ char *gidtoname(gid_t gid) struct group *grp; grp = getgrgid(gid); - if (grp) return(grp->gr_name); + if (grp) + return(grp->gr_name); slprintf(name,sizeof(name) - 1, "%d",(int)gid); return(name); } @@ -1408,10 +1413,10 @@ BOOL is_myname(char *s) /******************************************************************** Return only the first IP address of our configured interfaces - as a string. - ********************************************************************/ + as a string + *******************************************************************/ -const char *get_my_primary_ip (void) +const char* get_my_primary_ip (void) { static fstring ip_string; int n; @@ -1775,10 +1780,10 @@ int smb_mkstemp(char *template) #endif } - -/** +/***************************************************************** malloc that aborts with smb_panic on fail or zero size. -**/ + *****************************************************************/ + void *smb_xmalloc(size_t size) { void *p; @@ -1870,6 +1875,26 @@ char *lock_path(char *name) return fname; } +/***************************************************************** +a useful function for returning a path in the Samba pid directory + *****************************************************************/ +char *pid_path(char *name) +{ + static pstring fname; + + pstrcpy(fname,lp_piddir()); + trim_string(fname,"","/"); + + if (!directory_exist(fname,NULL)) { + mkdir(fname,0755); + } + + pstrcat(fname,"/"); + pstrcat(fname,name); + + return fname; +} + /** * @brief Returns an absolute path to a file in the Samba lib directory. |