charset.c: Split charset_initialise() into 2 - a charset_initialise() and
authorSamba Release Account <samba-bugs@samba.org>
Fri, 18 Jul 1997 20:21:32 +0000 (20:21 +0000)
committerSamba Release Account <samba-bugs@samba.org>
Fri, 18 Jul 1997 20:21:32 +0000 (20:21 +0000)
            a codepage_initialise(). Fixes problem with initialising dos map
            twice.
charset.h:  Changes to support charset changes.
client.c:   Changes to support charset changes.
loadparm.c: follow symlinks parameter from David Clerc <David.Clerc@cui.unige.ch>
nmbd.c: Changes to support charset changes.
nmblookup.c:Changes to support charset changes.
proto.h: Changes to support charset changes.
reply.c: Don't call security=server with no user/no password guest. Fix from
            Stefaan A Eeckels <Stefaan.Eeckels@ecc.lu>
server.c:   follow symlinks code from David Clerc <David.Clerc@cui.unige.ch>
smbpasswd.c:Changes to support charset changes.
status.c: Changes to support charset changes.
testparm.c: Changes to support charset changes.
testprns.c: Changes to support charset changes.
uid.c: Fixed log message with no \n.
Jeremy (jallison@whistle.com)
(This used to be commit 2a28a6e5e461aca7fe6c19cd01d287010056cffb)

14 files changed:
source3/client/client.c
source3/include/charset.h
source3/include/proto.h
source3/lib/charset.c
source3/nmbd/nmbd.c
source3/param/loadparm.c
source3/smbd/reply.c
source3/smbd/server.c
source3/smbd/uid.c
source3/utils/nmblookup.c
source3/utils/smbpasswd.c
source3/utils/status.c
source3/utils/testparm.c
source3/utils/testprns.c

index c7e00c4515028472e71f6ca389fe495619f737cd..dd739fdfa54712ff425785d20b9fa1a12dad1200 100644 (file)
@@ -4431,7 +4431,7 @@ static void usage(char *pname)
   setup_logging(pname,True);
 
   TimeInit();
-  charset_initialise(0);
+  charset_initialise();
 
   pid = getpid();
   uid = getuid();
index 25544fb62159f25517474aa539962d0e9eb20a93..5f5e2016ee1fa22750e1c054c47e8c47d73d37f8 100644 (file)
@@ -25,7 +25,7 @@ extern char *dos_char_map;
 extern char *upper_char_map;
 extern char *lower_char_map;
 extern void add_char_string(char *s);
-extern void charset_initialise(int);
+extern void charset_initialise(void);
 
 #ifdef toupper
 #undef toupper
index 5ba308561fa28e15d1f63c28d189ee406da53883..e9994214fb8052091ba4ef0020a6b2a2ff1367d9 100644 (file)
@@ -14,7 +14,8 @@ int interpret_character_set(char *str, int def);
 
 /*The following definitions come from  charset.c  */
 
-void charset_initialise(int client_codepage);
+void charset_initialise(void);
+void codepage_initialise(int client_codepage);
 void add_char_string(char *s);
 
 /*The following definitions come from  chgpasswd.c  */
@@ -243,6 +244,7 @@ BOOL lp_share_modes(int );
 BOOL lp_onlyuser(int );
 BOOL lp_manglednames(int );
 BOOL lp_widelinks(int );
+BOOL lp_symlinks(int );
 BOOL lp_syncalways(int );
 BOOL lp_map_system(int );
 BOOL lp_delete_readonly(int );
index f066b9a4728ba460a888a0999739c89bb36d4ff2..b463344daac1e330600a048e5b0fcb56b90b8375 100644 (file)
@@ -198,10 +198,9 @@ static void add_dos_char(int lower, BOOL map_lower_to_upper,
 /****************************************************************************
 initialise the charset arrays
 ****************************************************************************/
-void charset_initialise(int client_codepage)
+void charset_initialise()
 {
   int i;
-  unsigned char (*cp)[4];
 
 #ifdef LC_ALL
   /* include <locale.h> in includes.h if available for OS                  */
@@ -215,7 +214,7 @@ void charset_initialise(int client_codepage)
 
   for (i=0;i<=127;i++) {
     if (isalnum((char)i) || strchr("._^$~!#%&-{}()@'`",(char)i))
-      add_dos_char(i,0,False,False);
+      add_dos_char(i,False,0,False);
   }
 
   for (i=0; i<=255; i++) {
@@ -224,9 +223,17 @@ void charset_initialise(int client_codepage)
     if (isupper(c)) lower_char_map[i] = tolower(c);
     if (islower(c)) upper_char_map[i] = toupper(c);
   }
+}
 
- if(client_codepage != -1)
-   DEBUG(6,("charset_initialise: client code page = %d\n", client_codepage));
+/****************************************************************************
+initialise the client codepage.
+****************************************************************************/
+void codepage_initialise(int client_codepage)
+{
+  int i;
+  unsigned char (*cp)[4] = NULL;
+
+  DEBUG(6,("codepage_initialise: client code page = %d\n", client_codepage));
 
   /*
    * Known client codepages - these can be added to.
@@ -239,16 +246,12 @@ void charset_initialise(int client_codepage)
     case 437:
       cp = cp_437;
       break;
-    case -1: /* pre-initialize call so that toupper/tolower work
-                before smb.conf is read. */
-      cp = NULL;
-      break;
     default:
-      /* Default charset - currently 850 */
-      DEBUG(6,("charset_initialise: Using default client codepage %d\n", 850));
+      /* Use default codepage - currently 850 */
+      DEBUG(6,("codepage_initialise: Using default client codepage %d\n", 
+               850));
       cp = cp_850;
       break;
-    
   }
 
   if(cp)
index bf298293178f38f98a1fd855fb79ec9f519e55de..14611dc2c51db50ad01d05be9f22a3b1248d1fea 100644 (file)
@@ -421,7 +421,7 @@ static void usage(char *pname)
 
   setup_logging(argv[0],False);
 
-  charset_initialise(-1);
+  charset_initialise();
 
 #ifdef LMHOSTSFILE
   strcpy(host_file,LMHOSTSFILE);
@@ -498,7 +498,7 @@ static void usage(char *pname)
   if (!reload_services(False))
     return(-1);        
 
-  charset_initialise(lp_client_code_page());
+  codepage_initialise(lp_client_code_page());
 
   init_structs();
 
index af6c4657bfa52077fc27ff4e13b31bb5ecce3b24..89595caa0d82f28e76e83d4e8dd92fe39c498e79 100644 (file)
@@ -253,6 +253,7 @@ typedef struct
   BOOL bOnlyUser;
   BOOL bMangledNames;
   BOOL bWidelinks;
+  BOOL bSymlinks;
   BOOL bSyncAlways;
   char magic_char;
   BOOL *copymap;
@@ -332,6 +333,7 @@ static service sDefault =
   False, /* bOnlyUser */
   True,  /* bMangledNames */
   True,  /* bWidelinks */
+  True,  /* bSymlinks */
   False, /* bSyncAlways */
   '~',   /* magic char */
   NULL,  /* copymap */
@@ -528,6 +530,7 @@ struct parm_struct
   {"share modes",      P_BOOL,    P_LOCAL,  &sDefault.bShareModes,      NULL},
   {"only user",        P_BOOL,    P_LOCAL,  &sDefault.bOnlyUser,        NULL},
   {"wide links",       P_BOOL,    P_LOCAL,  &sDefault.bWidelinks,       NULL},
+  {"follow symlinks",  P_BOOL,    P_LOCAL,  &sDefault.bSymlinks,        NULL},
   {"sync always",      P_BOOL,    P_LOCAL,  &sDefault.bSyncAlways,      NULL},
   {"mangled names",    P_BOOL,    P_LOCAL,  &sDefault.bMangledNames,    NULL},
   {"fake oplocks",     P_BOOL,    P_LOCAL,  &sDefault.bFakeOplocks,     NULL},
@@ -920,6 +923,7 @@ FN_LOCAL_BOOL(lp_share_modes,bShareModes)
 FN_LOCAL_BOOL(lp_onlyuser,bOnlyUser)
 FN_LOCAL_BOOL(lp_manglednames,bMangledNames)
 FN_LOCAL_BOOL(lp_widelinks,bWidelinks)
+FN_LOCAL_BOOL(lp_symlinks,bSymlinks)
 FN_LOCAL_BOOL(lp_syncalways,bSyncAlways)
 FN_LOCAL_BOOL(lp_map_system,bMap_system)
 FN_LOCAL_BOOL(lp_delete_readonly,bDeleteReadonly)
index 315c7fbb51d00adbb5ded70622a39911ba717335..58695886641f778e8a70f2b5c5cee02b00a88982 100644 (file)
@@ -409,8 +409,14 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
   }
 
 
+  /* If no username is sent use the guest account */
   if (!*user)
-    strcpy(user,lp_guestaccount(-1));
+    {
+      strcpy(user,lp_guestaccount(-1));
+      /* If no user and no password then set guest flag. */
+      if( *smb_apasswd == 0)
+        guest = True;
+    }
 
   strlower(user);
 
@@ -421,24 +427,22 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
   add_session_user(user);
 
 
-  if (!(lp_security() == SEC_SERVER && server_validate(inbuf)) &&
+  if (!guest && !(lp_security() == SEC_SERVER && server_validate(inbuf)) &&
       !check_hosts_equiv(user))
     {
 
-      if (strequal(user,lp_guestaccount(-1)) && (*smb_apasswd == 0))
-       guest = True;
-  
       /* now check if it's a valid username/password */
       /* If an NT password was supplied try and validate with that
-        first. This is superior as the passwords are mixed case 128 length unicode */
-      if(smb_ntpasslen && !guest)
+        first. This is superior as the passwords are mixed case 
+         128 length unicode */
+      if(smb_ntpasslen)
        {
          if(!password_ok(user,smb_ntpasswd,smb_ntpasslen,NULL))
            DEBUG(0,("NT Password did not match ! Defaulting to Lanman\n"));
          else
            valid_nt_password = True;
        } 
-      if (!valid_nt_password && !guest && !password_ok(user,smb_apasswd,smb_apasslen,NULL))
+      if (!valid_nt_password && !password_ok(user,smb_apasswd,smb_apasslen,NULL))
        {
          if (!computer_id && lp_security() >= SEC_USER) {
 #if (GUEST_SESSSETUP == 0)
index 296962421560b0bffbeffb6dc1962cd7bcf8b066..5f5404bcc27e77076350aa00e14c7d07aacef558 100644 (file)
@@ -817,6 +817,22 @@ BOOL check_name(char *name,int cnum)
     }
 
   ret = reduce_name(name,Connections[cnum].connectpath,lp_widelinks(SNUM(cnum)));
+
+  /* Check if we are allowing users to follow symlinks */
+  /* Patch from David Clerc <David.Clerc@cui.unige.ch>
+     University of Geneva */
+
+  if (!lp_symlinks(SNUM(cnum)))
+    {
+      struct stat statbuf;
+      if ( (sys_lstat(name,&statbuf) != -1) &&
+          (S_ISLNK(statbuf.st_mode)) )
+        {
+          DEBUG(3,("check_name: denied: file path name %s is a symlink\n",name));
+          ret=0; 
+        }
+    }
+
   if (!ret)
     DEBUG(5,("check_name on %s failed\n",name));
 
@@ -4111,7 +4127,7 @@ static void usage(char *pname)
 
   setup_logging(argv[0],False);
 
-  charset_initialise(-1);
+  charset_initialise();
 
   /* make absolutely sure we run as root - to handle cases whre people
      are crazy enough to have it setuid */
@@ -4226,7 +4242,7 @@ static void usage(char *pname)
   if (!reload_services(False))
     return(-1);        
 
-  charset_initialise(lp_client_code_page());
+  codepage_initialise(lp_client_code_page());
 
   strcpy(myworkgroup, lp_workgroup());
 
index 0cf1c217a9be9fde48c2b9a0276af388d0870984..cdc4e474c61e8489f413c7c811f4500bc7ef703c 100644 (file)
@@ -83,7 +83,7 @@ static BOOL become_uid(int uid)
                &priv, sizeof(priv_t)) < 0 ||
        setuidx(ID_REAL|ID_EFFECTIVE, (uid_t)uid) < 0 ||
        seteuid((uid_t)uid) < 0) 
-      DEBUG(1,("Can't set uid (AIX3)"));
+      DEBUG(1,("Can't set uid (AIX3)\n"));
   }
 #endif
 
index 68093c10ede9cadea620534ec567e68008c19dbd..582f4eb6db387a599c4384d1689943e14905fbd6 100644 (file)
@@ -111,7 +111,7 @@ int main(int argc,char *argv[])
 
   setup_logging(argv[0],True);
 
-  charset_initialise(0);
+  charset_initialise();
 
   while ((opt = getopt(argc, argv, "p:d:B:i:s:SMh")) != EOF)
     switch (opt)
index 6867ff3b8a110083cc0e9566dc9b25df01aa546f..e03ebbaaef7bf9abdb8514e291d7afaf5a25bb32 100644 (file)
@@ -236,7 +236,7 @@ static void usage(char *name)
 
   setup_logging(argv[0],True);
   
-  charset_initialise(0);
+  charset_initialise();
   
 #ifndef DEBUG_PASSWORD
   /* Check the effective uid */
index 77fbc7fae116acc6ddcce527687d9cddc5e58f01..b439741e6c6a57239736e159d6e6b5a0fb9d4dea 100644 (file)
@@ -155,7 +155,7 @@ locking version (was %d, should be %d).\n",fname,
   TimeInit();
   setup_logging(argv[0],True);
 
-  charset_initialise(0);
+  charset_initialise();
 
   DEBUGLEVEL = 0;
   dbf = fopen("/dev/null","w");
index e9a848eb0b477409ef866b4560ec935e88170d50..81e69cd76fbe1006439c26c5d928b1a054fcd36a 100644 (file)
@@ -48,7 +48,7 @@ extern int DEBUGLEVEL;
 
   setup_logging(argv[0],True);
   
-  charset_initialise(0);
+  charset_initialise();
 
   if (argc < 2)
     strcpy(configfile,CONFIGFILE);
index c96ad476d296a5284701f5601bff8c8e96436e4a..4a2ddb7c6350d9a481fd5c0c2764c0db9931ced0 100644 (file)
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
 
    setup_logging(argv[0],True);
 
-   charset_initialise(0);
+   charset_initialise();
 
    if (argc < 2 || argc > 3)
       printf("Usage: testprns printername [printcapfile]\n");