Added 3 commands:
authorVolker Lendecke <vlendec@samba.org>
Mon, 5 Jan 1998 22:54:32 +0000 (22:54 +0000)
committerVolker Lendecke <vlendec@samba.org>
Mon, 5 Jan 1998 22:54:32 +0000 (22:54 +0000)
smbmount: This is a stripped down smbclient that communicates with
the Linux 2.1.x kernel to supply authenticated smb connections for
smbfs mount points.
smbmnt/smbumount: setuid commands that do the actual smb mount system
call after having done the appropriate security checks

source/client/client.c
source/client/clientutil.c
source/include/proto.h
source/include/smb.h

index e5fa3a4bf71b5547845c010479e71817ac87e900..49982760e1d03f774fbb415a50e35801b0193dec 100644 (file)
@@ -3387,7 +3387,7 @@ static BOOL process(char *base_directory)
   
   bzero(OutBuffer,smb_size);
 
-  if (!cli_send_login(InBuffer,OutBuffer,True,True))
+  if (!cli_send_login(InBuffer,OutBuffer,True,True,NULL))
     return(False);
 
   if (*base_directory) do_cd(base_directory);
@@ -3783,7 +3783,7 @@ static void usage(char *pname)
          return(1);
 
        bzero(OutBuffer,smb_size);
-       if (!cli_send_login(InBuffer,OutBuffer,True,True))
+       if (!cli_send_login(InBuffer,OutBuffer,True,True,NULL))
          return(False);
 
        if (*base_directory) do_cd(base_directory);
@@ -3808,7 +3808,7 @@ static void usage(char *pname)
 #if 0
          *username = 0;
 #endif
-         if (!cli_send_login(NULL,NULL,True,True))
+         if (!cli_send_login(NULL,NULL,True,True,NULL))
            return(1);
 
          server_info();
@@ -3859,7 +3859,7 @@ static void usage(char *pname)
 
                if (cli_open_sockets(port))
                {
-                       if (!cli_send_login(NULL,NULL,True,True)) return(1);
+                       if (!cli_send_login(NULL,NULL,True,True,NULL)) return(1);
 
                        do_nt_login(desthost, myhostname, Client, cnum);
 
index 9ce2c80d844aba15cc07efdcdb21e15ce82e3030..7c145bf59eeaff704b891942890972e75d3fa3dc 100644 (file)
@@ -428,20 +428,20 @@ static struct {
 /****************************************************************************
 send a login command.  
 ****************************************************************************/
-BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup)
+BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup, struct connection_options *options)
 {
   BOOL was_null = (!inbuf && !outbuf);
-  int sesskey=0;
   time_t servertime = 0;
   extern int serverzone;
-  int sec_mode=0;
-  int crypt_len;
-  int max_vcs=0;
+  int crypt_len=0;
   char *pass = NULL;  
   pstring dev;
   char *p;
   int numprots;
   int tries=0;
+  struct connection_options opt;
+
+  bzero(&opt, sizeof(opt));
 
   if (was_null)
     {
@@ -516,34 +516,35 @@ BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup)
       return(False);
     }
 
-  Protocol = prots[SVAL(inbuf,smb_vwv0)].prot;
+  opt.protocol = Protocol = prots[SVAL(inbuf,smb_vwv0)].prot;
 
 
   if (Protocol < PROTOCOL_LANMAN1) {    
          /* no extra params */
   } else if (Protocol < PROTOCOL_NT1) {
-    sec_mode = SVAL(inbuf,smb_vwv1);
-    max_xmit = SVAL(inbuf,smb_vwv2);
-    sesskey = IVAL(inbuf,smb_vwv6);
-    serverzone = SVALS(inbuf,smb_vwv10)*60;
+    opt.sec_mode = SVAL(inbuf,smb_vwv1);
+    opt.max_xmit = max_xmit = SVAL(inbuf,smb_vwv2);
+    opt.sesskey = IVAL(inbuf,smb_vwv6);
+    opt.serverzone = serverzone = SVALS(inbuf,smb_vwv10)*60;
     /* this time is converted to GMT by make_unix_date */
     servertime = make_unix_date(inbuf+smb_vwv8);
     if (Protocol >= PROTOCOL_COREPLUS) {
+      opt.rawmode = SVAL(inbuf,smb_vwv5);
       readbraw_supported = ((SVAL(inbuf,smb_vwv5) & 0x1) != 0);
       writebraw_supported = ((SVAL(inbuf,smb_vwv5) & 0x2) != 0);
     }
     crypt_len = smb_buflen(inbuf);
     memcpy(cryptkey,smb_buf(inbuf),8);
     DEBUG(3,("max mux %d\n",SVAL(inbuf,smb_vwv3)));
-    max_vcs = SVAL(inbuf,smb_vwv4); 
-    DEBUG(3,("max vcs %d\n",max_vcs)); 
+    opt.max_vcs = SVAL(inbuf,smb_vwv4); 
+    DEBUG(3,("max vcs %d\n",opt.max_vcs)); 
     DEBUG(3,("max blk %d\n",SVAL(inbuf,smb_vwv5)));
   } else {
     /* NT protocol */
-    sec_mode = CVAL(inbuf,smb_vwv1);
-    max_xmit = IVAL(inbuf,smb_vwv3+1);
-    sesskey = IVAL(inbuf,smb_vwv7+1);
-    serverzone = SVALS(inbuf,smb_vwv15+1)*60;
+    opt.sec_mode = CVAL(inbuf,smb_vwv1);
+    opt.max_xmit = max_xmit = IVAL(inbuf,smb_vwv3+1);
+    opt.sesskey = IVAL(inbuf,smb_vwv7+1);
+    opt.serverzone = SVALS(inbuf,smb_vwv15+1)*60;
     /* this time arrives in real GMT */
     servertime = interpret_long_date(inbuf+smb_vwv11+1);
     crypt_len = CVAL(inbuf,smb_vwv16+1);
@@ -551,8 +552,8 @@ BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup)
     if (IVAL(inbuf,smb_vwv9+1) & 1)
       readbraw_supported = writebraw_supported = True;      
     DEBUG(3,("max mux %d\n",SVAL(inbuf,smb_vwv1+1)));
-    max_vcs = SVAL(inbuf,smb_vwv2+1); 
-    DEBUG(3,("max vcs %d\n",max_vcs));
+    opt.max_vcs = SVAL(inbuf,smb_vwv2+1); 
+    DEBUG(3,("max vcs %d\n",opt.max_vcs));
     DEBUG(3,("max raw %d\n",IVAL(inbuf,smb_vwv5+1)));
     DEBUG(3,("capabilities 0x%x\n",IVAL(inbuf,smb_vwv9+1)));
   }
@@ -562,7 +563,7 @@ BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup)
   DEBUG(3,("Got %d byte crypt key\n",crypt_len));
   DEBUG(3,("Chose protocol [%s]\n",prots[SVAL(inbuf,smb_vwv0)].name));
 
-  doencrypt = ((sec_mode & 2) != 0);
+  doencrypt = ((opt.sec_mode & 2) != 0);
 
   if (servertime) {
     static BOOL done_time = False;
@@ -600,7 +601,7 @@ BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup)
       }
 
       /* if in share level security then don't send a password now */
-      if (!(sec_mode & 1)) {strcpy(pword, "");passlen=1;} 
+      if (!(opt.sec_mode & 1)) {strcpy(pword, "");passlen=1;} 
 
       /* send a session setup command */
       bzero(outbuf,smb_size);
@@ -613,8 +614,8 @@ BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup)
        CVAL(outbuf,smb_vwv0) = 0xFF;
        SSVAL(outbuf,smb_vwv2,max_xmit);
        SSVAL(outbuf,smb_vwv3,2);
-       SSVAL(outbuf,smb_vwv4,max_vcs-1);
-       SIVAL(outbuf,smb_vwv5,sesskey);
+       SSVAL(outbuf,smb_vwv4,opt.max_vcs-1);
+       SIVAL(outbuf,smb_vwv5,opt.sesskey);
        SSVAL(outbuf,smb_vwv7,passlen);
        p = smb_buf(outbuf);
        memcpy(p,pword,passlen);
@@ -631,7 +632,7 @@ BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup)
        SSVAL(outbuf,smb_vwv2,BUFFER_SIZE);
        SSVAL(outbuf,smb_vwv3,2);
        SSVAL(outbuf,smb_vwv4,getpid());
-       SIVAL(outbuf,smb_vwv5,sesskey);
+       SIVAL(outbuf,smb_vwv5,opt.sesskey);
        SSVAL(outbuf,smb_vwv7,passlen);
        SSVAL(outbuf,smb_vwv8,0);
        p = smb_buf(outbuf);
@@ -688,10 +689,10 @@ BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup)
       if (SVAL(inbuf,smb_uid) != uid)
        DEBUG(3,("Server gave us a UID of %d. We gave %d\n",
              SVAL(inbuf,smb_uid),uid));
-      uid = SVAL(inbuf,smb_uid);
+      opt.server_uid = uid = SVAL(inbuf,smb_uid);
     }
 
-  if (sec_mode & 1) {
+  if (opt.sec_mode & 1) {
          if (SVAL(inbuf, smb_vwv2) & 1)
                  DEBUG(1,("connected as guest "));
          DEBUG(1,("security=user\n"));
@@ -722,7 +723,7 @@ BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup)
     }
 
     /* if in user level security then don't send a password now */
-    if ((sec_mode & 1)) {
+    if ((opt.sec_mode & 1)) {
       strcpy(pword, ""); passlen=1; 
     }
 
@@ -798,6 +799,8 @@ BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup)
 
     cnum = SVAL(inbuf,smb_tid);
   }
+  opt.max_xmit = max_xmit;
+  opt.tid = cnum;
 
   DEBUG(3,("Connected with cnum=%d max_xmit=%d\n",cnum,max_xmit));
 
@@ -807,6 +810,11 @@ BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup)
       free(outbuf);
     }
 
+  if (options != NULL)
+    {
+      *options = opt;
+    }
+
   return True;
 }
 
@@ -951,6 +959,6 @@ BOOL cli_reopen_connection(char *inbuf,char *outbuf)
   close_sockets();
   if (!cli_open_sockets(0)) return(False);
 
-  return(cli_send_login(inbuf,outbuf,True,True));
+  return(cli_send_login(inbuf,outbuf,True,True,NULL));
 }
 
index 1245b21039c0c36e64d019eb52e030c05dbaf80b..e26c1889a152a42ead968a3e52a0a846ea822a77 100644 (file)
@@ -114,7 +114,7 @@ BOOL cli_send_trans_request(char *outbuf,int trans,
                               int ldata,int lparam,int lsetup,
                               int mdata,int mparam,int msetup);
 BOOL cli_send_session_request(char *inbuf,char *outbuf);
-BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup);
+BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup, struct connection_options *options);
 void cli_send_logout(void );
 BOOL cli_open_sockets(int port );
 BOOL cli_reopen_connection(char *inbuf,char *outbuf);
index 401459becc237e8a5ef4e700cf09c6e10cbce9c6..ebf0945855efa55fa83af484e5053cf363314407 100644 (file)
@@ -1628,6 +1628,25 @@ struct connect_record
   time_t start;
 };
 
+/* This is used by smbclient to send it to a smbfs mount point */
+struct connection_options {
+  int protocol;
+  /* Connection-Options */
+  uint32 max_xmit;
+  uint16 server_uid;
+  uint16 tid;
+  /* The following are LANMAN 1.0 options */
+  uint16 sec_mode;
+  uint16 max_mux;
+  uint16 max_vcs;
+  uint16 rawmode;
+  uint32 sesskey;
+  /* The following are NT LM 0.12 options */
+  uint32 maxraw;
+  uint32 capabilities;
+  uint16 serverzone;
+};
+
 #ifndef LOCKING_VERSION
 #define LOCKING_VERSION 4
 #endif /* LOCKING_VERSION */