- made FAST_SHARE_MODES standard for Linux
authorAndrew Tridgell <tridge@samba.org>
Sat, 17 Aug 1996 14:27:12 +0000 (14:27 +0000)
committerAndrew Tridgell <tridge@samba.org>
Sat, 17 Aug 1996 14:27:12 +0000 (14:27 +0000)
- you can now press enter after a password prompt with "smbclient -L
hostname" and it will use a blank username and password, the same as
if you used -U%

- changed the wins.dat store code to not go via a string variable
(just use fprintf instead)

- removed a "unsigned long" that luke put back in, changing it to
uint32 to keep 64 bit machines happy. Naughtly luke!

- allow guest non-connnected print queue listings so ms client 3 can
work
(This used to be commit 917160dee69bbc198985b6f3232ca2dcda809d8a)

source3/client/client.c
source3/include/includes.h
source3/include/proto.h
source3/locking/locking.c
source3/locking/shmem.c
source3/namedbname.c
source3/smbd/server.c
source3/utils/status.c

index a6bb50cb3d88a0279afefc5cbfd89dfaede07d4a..b0e4f4a0044fe291ef53d780b3486b5c85a78bad 100644 (file)
@@ -2523,7 +2523,7 @@ static void cmd_qinfo(char *inbuf,char *outbuf )
   char *p;
   int rdrcnt, rprcnt;
   pstring param;
-  int result_code;
+  int result_code=0;
   
   bzero(param,sizeof(param));
 
@@ -3037,6 +3037,7 @@ static BOOL send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setu
   pstring dev;
   char *p;
   int numprots;
+  int tries=0;
 
   if (was_null)
     {
@@ -3174,6 +3175,10 @@ static BOOL send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setu
   else
     pass = (char *)getpass("Password: ");
 
+  /* use a blank username for the 2nd try with a blank password */
+  if (tries++ && !*pass)
+    *username = 0;
+
   if (Protocol >= PROTOCOL_LANMAN1 && use_setup)
     {
       fstring pword;
index 79400683fe56f005f239f16cc87cf092ae8ef2e1..35ef18055ced7d7f04f9a1a8cdcea622068ec042 100644 (file)
 #endif
 #endif
 
-#if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
-#include <sys/mman.h>
-#endif
-
 #if defined(GETPWANAM)
 #include <sys/types.h>
 #include <sys/label.h>
@@ -224,6 +220,7 @@ Here come some platform specific sections
 #define HAVE_BZERO
 #define HAVE_MEMMOVE
 #define USE_SIGPROCMASK
+#define FAST_SHARE_MODES 1
 #if 0
 /* SETFS disabled until we can check on some bug reports */
 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
@@ -909,6 +906,10 @@ typedef int mode_t;
 end of the platform specific sections
 ********************************************************************/
 
+#if defined(USE_MMAP) || FAST_SHARE_MODES
+#include <sys/mman.h>
+#endif
+
 #ifdef SecureWare
 #define NEED_AUTH_PARAMETERS
 #endif
index 87ad286df303f74af32f7917d23af4a58f62ad88..c1697dc6416c2b39b71dabd3a937ff6ba73cde78 100644 (file)
@@ -796,11 +796,6 @@ BOOL become_user(int cnum, int uid);
 BOOL unbecome_user(void );
 int smbrun(char *cmd,char *outfile);
 
-/*The following definitions come from  unxlog.c  */
-
-void write_utmp(int dologin, int connection, int pid,
-                char *from_addr, char *username);
-
 /*The following definitions come from  username.c  */
 
 char *get_home_dir(char *user);
index 60428f2e984a7dfcf67885d5031da85649a7f3b5..966bb2253b7e971dcd2d000bfd2e5e39a035bb94 100644 (file)
@@ -231,7 +231,7 @@ BOOL do_unlock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *
   return True; /* Did unlock */
 }
 
-#ifdef FAST_SHARE_MODES
+#if FAST_SHARE_MODES
 /*******************************************************************
   initialize the shared memory for share_mode management 
   ******************************************************************/
@@ -312,7 +312,7 @@ get the share mode of a file
 ********************************************************************/
 int get_share_mode(int cnum,struct stat *sbuf,int *pid)
 {
-#ifdef FAST_SHARE_MODES
+#if FAST_SHARE_MODES
   share_mode_record *scanner_p;
   share_mode_record *prev_p;
   int ret;
@@ -434,7 +434,7 @@ del the share mode of a file, if we set it last
 ********************************************************************/
 void del_share_mode(int fnum)
 {
-#ifdef FAST_SHARE_MODES
+#if FAST_SHARE_MODES
   struct stat st;
   time_t t=0;
   int pid=0;
@@ -540,7 +540,7 @@ set the share mode of a file
 ********************************************************************/
 BOOL set_share_mode(int fnum,int mode)
 {
-#ifdef FAST_SHARE_MODES
+#if FAST_SHARE_MODES
   int pid = (int)getpid();
   struct stat st;
   shm_offset_t new_off;
index 3a308d07baf227a8494ddf662e2604d33d966909..f68059afa2c613ad68f77ee55534e73153fbff82 100644 (file)
 
 */
 
-#ifdef FAST_SHARE_MODES
+#include "includes.h"
 
 
-#include "includes.h"
+#if FAST_SHARE_MODES
+
 
 extern int DEBUGLEVEL;
 
index b8edfa255413c5c95851715ecee0dcbc9a978246..188e46ff7595bbaa22370513e28b09bbdd77eed2 100644 (file)
@@ -230,8 +230,8 @@ void dump_names(void)
     {
       int i;
 
-         DEBUG(3,("%15s ", inet_ntoa(d->bcast_ip)));
-         DEBUG(3,("%15s ", inet_ntoa(d->mask_ip)));
+      DEBUG(3,("%15s ", inet_ntoa(d->bcast_ip)));
+      DEBUG(3,("%15s ", inet_ntoa(d->mask_ip)));
       DEBUG(3,("%-19s TTL=%ld ",
               namestr(&n->name),
               n->death_time?n->death_time-t:0));
@@ -243,35 +243,29 @@ void dump_names(void)
                                                n->ip_flgs[i].nb_flags));
 
         }
-               DEBUG(3,("\n"));
+       DEBUG(3,("\n"));
 
       if (f && ip_equal(d->bcast_ip, ipgrp) && n->source == REGISTER)
       {
-        fstring data;
-
       /* XXXX i have little imagination as to how to output nb_flags as
          anything other than as a hexadecimal number :-) */
 
-        sprintf(data, "%s#%02x %ld",
-              n->name.name,n->name.name_type, /* XXXX ignore scope for now */
-              n->death_time);
-           fprintf(f, "%s", data);
+        fprintf(f,"%s#%02x %ld",
+               n->name.name,n->name.name_type, /* XXXX ignore scope for now */
+               n->death_time);
         for (i = 0; i < n->num_ips; i++)
         {
            DEBUG(3,("%15s NB=%2x ",
-                                               inet_ntoa(n->ip_flgs[i].ip),
-                                               n->ip_flgs[i].nb_flags));
+                   inet_ntoa(n->ip_flgs[i].ip),
+                   n->ip_flgs[i].nb_flags));
 
-           sprintf(data, "%s %2x ",
-                                               inet_ntoa(n->ip_flgs[i].ip),
-                                               n->ip_flgs[i].nb_flags);
-   
-                  fprintf(f, "%s", data);
+           fprintf(f, "%s %2x ",
+                  inet_ntoa(n->ip_flgs[i].ip),
+                  n->ip_flgs[i].nb_flags);   
         }
-               DEBUG(3,("\n"));
-               fprintf(f, "\n");
+       DEBUG(3,("\n"));
+       fprintf(f, "\n");
       }
-
     }
 
   fclose(f);
@@ -318,34 +312,31 @@ void load_netbios_names(void)
       int type = 0;
       int nb_flags;
       time_t ttd;
-         struct in_addr ipaddr;
-
-         enum name_source source;
-
+      struct in_addr ipaddr;
+      enum name_source source;
       char *ptr;
-         int count = 0;
-
+      int count = 0;
       char *p;
 
       if (!fgets_slash(line,sizeof(pstring),f)) continue;
 
       if (*line == '#') continue;
 
-       ptr = line;
-
-       if (next_token(&ptr,name_str    ,NULL)) ++count;
-       if (next_token(&ptr,ttd_str     ,NULL)) ++count;
-       if (next_token(&ptr,ip_str      ,NULL)) ++count;
-       if (next_token(&ptr,nb_flags_str,NULL)) ++count;
+      ptr = line;
 
-       if (count <= 0) continue;
+      if (next_token(&ptr,name_str    ,NULL)) ++count;
+      if (next_token(&ptr,ttd_str     ,NULL)) ++count;
+      if (next_token(&ptr,ip_str      ,NULL)) ++count;
+      if (next_token(&ptr,nb_flags_str,NULL)) ++count;
 
-       if (count != 4) {
-         DEBUG(0,("Ill formed wins line"));
-         DEBUG(0,("[%s]: name#type ip nb_flags abs_time\n",line));
-         continue;
-       }
+      if (count <= 0) continue;
 
+      if (count != 4) {
+       DEBUG(0,("Ill formed wins line"));
+       DEBUG(0,("[%s]: name#type ip nb_flags abs_time\n",line));
+       continue;
+      }
+      
       /* netbios name. # divides the name from the type (hex): netbios#xx */
       strcpy(name,name_str);
 
@@ -357,10 +348,10 @@ void load_netbios_names(void)
       }
 
       /* decode the netbios flags (hex) and the time-to-die (seconds) */
-         sscanf(nb_flags_str,"%x",&nb_flags);
-         sscanf(ttd_str,"%ld",&ttd);
+      sscanf(nb_flags_str,"%x",&nb_flags);
+      sscanf(ttd_str,"%ld",&ttd);
 
-         ipaddr = *interpret_addr2(ip_str);
+      ipaddr = *interpret_addr2(ip_str);
 
       if (ip_equal(ipaddr,ipzero)) {
          source = SELF;
@@ -545,7 +536,7 @@ struct name_record *search_for_name(struct subnet_record **d,
   if (!n)
     {
       struct in_addr dns_ip;
-      unsigned long a;
+      uint32 a;
       
       /* only do DNS lookups if the query is for type 0x20 or type 0x0 */
       if (!dns_type && name_type != 0x1b)
index 3889440975a7620d4f4e3e386deeaecadd77767b..403b41e86b59f8a1e2e7ee165ff822e8a5a648c3 100644 (file)
@@ -3026,7 +3026,7 @@ struct smb_message_struct
    {SMBctemp,"SMBctemp",reply_ctemp,AS_USER},
    {SMBsplopen,"SMBsplopen",reply_printopen,AS_USER},
    {SMBsplclose,"SMBsplclose",reply_printclose,AS_USER},
-   {SMBsplretq,"SMBsplretq",reply_printqueue,AS_USER},
+   {SMBsplretq,"SMBsplretq",reply_printqueue,AS_USER|AS_GUEST},
    {SMBsplwr,"SMBsplwr",reply_printwrite,AS_USER},
    {SMBlock,"SMBlock",reply_lock,AS_USER},
    {SMBunlock,"SMBunlock",reply_unlock,AS_USER},
@@ -3159,8 +3159,17 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize
            unbecome_user();
 
          /* does this protocol need to be run as the connected user? */
-         if ((flags & AS_USER) && !become_user(cnum,uid))
-           return(ERROR(ERRSRV,ERRinvnid));
+         if ((flags & AS_USER) && !become_user(cnum,uid)) {
+           if (flags & AS_GUEST) 
+             flags &= ~AS_USER;
+           else
+             return(ERROR(ERRSRV,ERRinvnid));
+         }
+         /* this code is to work around a bug is MS client 3 without
+            introducing a security hole - it needs to be able to do
+            print queue checks as guest if it isn't logged in properly */
+         if (flags & AS_USER)
+           flags &= ~AS_GUEST;
 
          /* does it need write permission? */
          if ((flags & NEED_WRITE) && !CAN_WRITE(cnum))
@@ -3744,7 +3753,7 @@ static void usage(char *pname)
   if (!open_sockets(is_daemon,port))
     exit(1);
 
-#ifdef FAST_SHARE_MODES
+#if FAST_SHARE_MODES
   if (!start_share_mode_mgmt())
     exit(1);
 #endif
@@ -3763,7 +3772,7 @@ static void usage(char *pname)
   process();
   close_sockets();
 
-#ifdef FAST_SHARE_MODES
+#if FAST_SHARE_MODES
   stop_share_mode_mgmt();
 #endif
 
index c9fda5d359809c81130c029e2bc928bc044666ee..ab61a4db89ba7814c3b3ae0e64f749a77bfd7d54 100644 (file)
@@ -55,7 +55,7 @@ unsigned int   Ucrit_IsActive = 0;                    /* added by OH */
   BOOL firstopen=True;
   BOOL processes_only=False;
   int last_pid=0;
-#ifdef FAST_SHARE_MODES
+#if FAST_SHARE_MODES
   pstring shmem_file_name;
   share_mode_record *scanner_p;
   share_mode_record *prev_p;
@@ -165,7 +165,7 @@ unsigned int   Ucrit_IsActive = 0;                    /* added by OH */
 
   printf("\n");
 
-#ifdef FAST_SHARE_MODES
+#if FAST_SHARE_MODES
   /*******************************************************************
   initialize the shared memory for share_mode management 
   ******************************************************************/
@@ -286,7 +286,7 @@ unsigned int   Ucrit_IsActive = 0;                    /* added by OH */
       }
     printf(" %s   %s",fname,asctime(LocalTime(&t)));
 
-#ifdef FAST_SHARE_MODES
+#if FAST_SHARE_MODES
      prev_p = scanner_p ;
      scanner_p = (share_mode_record *)shm_offset2addr(scanner_p->next_offset);
   } /* end while */
@@ -307,7 +307,7 @@ unsigned int   Ucrit_IsActive = 0;                    /* added by OH */
 #endif
   if (firstopen)
     printf("No locked files\n");
-#ifdef FAST_SHARE_MODES
+#if FAST_SHARE_MODES
   printf("\nShare mode memory usage (bytes):\n");
   printf("   %d(%d%%) free + %d(%d%%) used + %d(%d%%) overhead = %d(100%%) total\n",
         bytes_free, (bytes_free * 100)/bytes_total,