From b26623bc3a8ff5191763c83564453e77edee836a Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sun, 2 Nov 1997 20:35:20 +0000 Subject: Christian Lademann's contribution: new capabilities in smb.conf. '<' and '|' characters indicate read file and execute command respectively, and feed the output into the parameter (!!!). '<$' and '|$' means run standard_sub_basic() on them. this is going to be fun to document in smb.conf.5.... also, Christian created a new "online" service parameter. services can be taken "off-line".... (This used to be commit 15f44d28916cdc1432bffdbb999c7cf7efd8fb86) --- source3/include/proto.h | 4 ++ source3/lib/util.c | 41 +++++++++++++ source3/param/loadparm.c | 154 ++++++++++++++++++++++++++++++++++------------- source3/smbd/reply.c | 4 +- source3/smbd/server.c | 23 ++++--- 5 files changed, 174 insertions(+), 52 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index e4601672e0..d592c94634 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -183,6 +183,8 @@ int interpret_coding_system(char *str, int def); /*The following definitions come from loadparm.c */ +char *chomp(char *s); +char *read_string_external(char *fname); char *lp_string(char *s); char *lp_logfile(void); char *lp_smbrun(void); @@ -329,6 +331,7 @@ BOOL lp_syncalways(int ); BOOL lp_map_system(int ); BOOL lp_delete_readonly(int ); BOOL lp_fake_oplocks(int ); +BOOL lp_online(int ); BOOL lp_recursive_veto_delete(int ); BOOL lp_dos_filetimes(int ); int lp_create_mode(int ); @@ -1271,3 +1274,4 @@ char *align_offset(char *q, char *base, int align_offset_len); void print_asc(int level, unsigned char *buf,int len); void dump_data(int level,char *buf1,int len); char *tab_depth(int depth); +char *string_buffer(int sz); diff --git a/source3/lib/util.c b/source3/lib/util.c index 4d098013f2..9ee9bbab1c 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -4561,3 +4561,44 @@ char *tab_depth(int depth) } +/******************************************************************* +A convenience routine to grab string parameters into a rotating +buffer. The buffers can be written to by callers without affecting +the source string. +********************************************************************/ +char *string_buffer(int sz) +{ + static char *bufs[10]; + static int buflen[10]; + static int next = -1; + char *ret; + int i, len; + + if (next == -1) { + /* initialisation */ + for (i=0;i<10;i++) { + bufs[i] = NULL; + buflen[i] = 0; + } + next = 0; + } + + len = MAX(sz+100,sizeof(pstring)); /* the +100 is for some + substitution room */ + + if (buflen[next] != len) { + buflen[next] = len; + if (bufs[next]) free(bufs[next]); + bufs[next] = (char *)malloc(len); + if (!bufs[next]) { + DEBUG(0,("out of memory in lp_string_buffer()")); + exit(1); + } + } + + ret = &bufs[next][0]; + next = (next+1)%10; + *ret = 0; + + return(ret); +} diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 2fe616f709..a798444676 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -278,6 +278,7 @@ typedef struct BOOL *copymap; BOOL bDeleteReadonly; BOOL bFakeOplocks; + BOOL bOnline; BOOL bDeleteVetoFiles; BOOL bDosFiletimes; char dummy[3]; /* for alignment */ @@ -362,6 +363,7 @@ static service sDefault = NULL, /* copymap */ False, /* bDeleteReadonly */ False, /* bFakeOplocks */ + True, /* bOnline */ False, /* bDeleteVetoFiles */ False, /* bDosFiletimes */ "" /* dummy */ @@ -594,6 +596,7 @@ struct parm_struct {"magic output", P_STRING, P_LOCAL, &sDefault.szMagicOutput, NULL}, {"mangled map", P_STRING, P_LOCAL, &sDefault.szMangledMap, NULL}, {"delete readonly", P_BOOL, P_LOCAL, &sDefault.bDeleteReadonly, NULL}, + {"online", P_BOOL, P_LOCAL, &sDefault.bOnline, NULL}, {"dos filetimes", P_BOOL, P_LOCAL, &sDefault.bDosFiletimes, NULL}, {NULL, P_BOOL, P_NONE, NULL, NULL} @@ -772,57 +775,108 @@ static void init_locals(void) } -/******************************************************************* a -convenience routine to grab string parameters into a rotating buffer, -and run standard_sub_basic on them. The buffers can be written to by -callers without affecting the source string. -********************************************************************/ -char *lp_string(char *s) + +/* chomp() strips off trailing linefeed- and carriage-return-characters */ +char *chomp(char *s) { - static char *bufs[10]; - static int buflen[10]; - static int next = -1; - char *ret; - int i; - int len = s?strlen(s):0; + if(!s || s == NULL) +return(NULL); - if (next == -1) { - /* initialisation */ - for (i=0;i<10;i++) { - bufs[i] = NULL; - buflen[i] = 0; - } - next = 0; - } + while(strlen(s) > 0) { + int i = strlen(s) - 1; - len = MAX(len+100,sizeof(pstring)); /* the +100 is for some - substitution room */ + if(s [i] == '\n' || s [i] == '\r') + s [i] = '\0'; + else + break; + } - if (buflen[next] != len) { - buflen[next] = len; - if (bufs[next]) free(bufs[next]); - bufs[next] = (char *)malloc(len); - if (!bufs[next]) { - DEBUG(0,("out of memory in lp_string()")); - exit(1); - } - } + return(s); +} - ret = &bufs[next][0]; - next = (next+1)%10; - if (!s) - *ret = 0; - else - StrCpy(ret,s); +/* +read_string_external(fname): depending on the first character in fname either +reads the first line of a file or of the output of a command. If the second +character is a '$' execute standard-substitutions on the string to be returned. + +examples: read_string_external("