spelling
[tprouty/samba.git] / source / smbd / service.c
index f67361e66a3db4f5c3652f943352fe4bc80c9ad3..c9f5330551485407f808c631038a0ca665c040cf 100644 (file)
@@ -227,22 +227,27 @@ static NTSTATUS share_sanity_checks(int snum, fstring dev)
                return NT_STATUS_ACCESS_DENIED;
        }
 
-       /* you can only connect to the IPC$ service as an ipc device */
-       if (strequal(lp_fstype(snum), "IPC"))
-               fstrcpy(dev,"IPC");
-       
        if (dev[0] == '?' || !dev[0]) {
                if (lp_print_ok(snum)) {
                        fstrcpy(dev,"LPT1:");
+               } else if (strequal(lp_fstype(snum), "IPC")) {
+                       fstrcpy(dev, "IPC");
                } else {
                        fstrcpy(dev,"A:");
                }
        }
 
-       /* if the request is as a printer and you can't print then refuse */
        strupper(dev);
-       if (!lp_print_ok(snum) && (strncmp(dev,"LPT",3) == 0)) {
-               DEBUG(1,("Attempt to connect to non-printer as a printer\n"));
+
+       if (lp_print_ok(snum)) {
+               if (!strequal(dev, "LPT1:")) {
+                       return NT_STATUS_BAD_DEVICE_TYPE;
+               }
+       } else if (strequal(lp_fstype(snum), "IPC")) {
+               if (!strequal(dev, "IPC")) {
+                       return NT_STATUS_BAD_DEVICE_TYPE;
+               }
+       } else if (!strequal(dev, "A:")) {
                return NT_STATUS_BAD_DEVICE_TYPE;
        }
 
@@ -481,13 +486,14 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
                pstring tmp_gname;
                BOOL user_must_be_member = False;
                
-               StrnCpy(tmp_gname,lp_force_group(snum),sizeof(pstring)-1);
+               pstrcpy(tmp_gname,lp_force_group(snum));
                
                if (tmp_gname[0] == '+') {
                        user_must_be_member = True;
-                       StrnCpy(gname,&tmp_gname[1],sizeof(pstring)-2);
+                       /* even now, tmp_gname is null terminated */
+                       pstrcpy(gname,&tmp_gname[1]);
                } else {
-                       StrnCpy(gname,tmp_gname,sizeof(pstring)-1);
+                       pstrcpy(gname,tmp_gname);
                }
                /* default service may be a group name          */
                pstring_sub(gname,"%S",lp_servicename(snum));
@@ -786,7 +792,7 @@ connection_struct *make_connection(const char *service_in, DATA_BLOB password,
                if(lp_security() != SEC_SHARE) {
                        DATA_BLOB no_pw = data_blob(NULL, 0);
                        if (vuser->homes_snum == -1) {
-                               DEBUG(2, ("[homes] share not available for this user becouse it was not found or created at session setup time\n"));
+                               DEBUG(2, ("[homes] share not available for this user because it was not found or created at session setup time\n"));
                                *status = NT_STATUS_BAD_NETWORK_NAME;
                                return NULL;
                        }