Author: vlendec
Date: 2006-07-26 06:59:50 +0000 (Wed, 26 Jul 2006)
New Revision: 17252

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=17252

Log:
merge -r17232:17251
Modified:
   branches/tmp/vl-messaging/source/lib/messages.c
   branches/tmp/vl-messaging/source/libads/dns.c
   branches/tmp/vl-messaging/source/libsmb/errormap.c
   branches/tmp/vl-messaging/source/passdb/pdb_smbpasswd.c
   branches/tmp/vl-messaging/source/rpc_server/srv_spoolss_nt.c
   branches/tmp/vl-messaging/source/smbd/open.c


Changeset:
Modified: branches/tmp/vl-messaging/source/lib/messages.c
===================================================================
--- branches/tmp/vl-messaging/source/lib/messages.c     2006-07-26 06:18:13 UTC 
(rev 17251)
+++ branches/tmp/vl-messaging/source/lib/messages.c     2006-07-26 06:59:50 UTC 
(rev 17252)
@@ -211,7 +211,7 @@
 
 BOOL message_send_pid_with_timeout(struct process_id pid, int msg_type,
                                   const void *buf, size_t len,
-               BOOL duplicates_allowed, unsigned int timeout)
+                                  BOOL duplicates_allowed, unsigned int 
timeout)
 {
        return message_send_pid_internal(pid, msg_type, buf, len,
                                         duplicates_allowed, timeout);

Modified: branches/tmp/vl-messaging/source/libads/dns.c
===================================================================
--- branches/tmp/vl-messaging/source/libads/dns.c       2006-07-26 06:18:13 UTC 
(rev 17251)
+++ branches/tmp/vl-messaging/source/libads/dns.c       2006-07-26 06:59:50 UTC 
(rev 17252)
@@ -245,17 +245,11 @@
 
 static int dnssrvcmp( struct dns_rr_srv *a, struct dns_rr_srv *b )
 {
-       BOOL init = False;
-
-       if ( !init ) {
-               srand( (uint32)time(NULL) );
-       }
-
        if ( a->priority == b->priority ) {
 
                /* randomize entries with an equal weight and priority */
                if ( a->weight == b->weight ) 
-                       return rand() % 2 ? -1 : 1;
+                       return 0;
 
                /* higher weights should be sorted lower */ 
                if ( a->weight > b->weight )
@@ -349,7 +343,7 @@
        DEBUG(4,("ads_dns_lookup_srv: %d records returned in the answer 
section.\n", 
                answer_count));
                
-       if ( (dcs = TALLOC_ARRAY(ctx, struct dns_rr_srv, answer_count)) == NULL 
) {
+       if ( (dcs = TALLOC_ZERO_ARRAY(ctx, struct dns_rr_srv, answer_count)) == 
NULL ) {
                DEBUG(0,("ads_dns_lookup_srv: talloc() failure for %d 
char*'s\n", 
                        answer_count));
                return NT_STATUS_NO_MEMORY;

Modified: branches/tmp/vl-messaging/source/libsmb/errormap.c
===================================================================
--- branches/tmp/vl-messaging/source/libsmb/errormap.c  2006-07-26 06:18:13 UTC 
(rev 17251)
+++ branches/tmp/vl-messaging/source/libsmb/errormap.c  2006-07-26 06:59:50 UTC 
(rev 17252)
@@ -779,7 +779,11 @@
        {ERRHRD,        ERRlock,        NT_STATUS_FILE_LOCK_CONFLICT},
        {ERRHRD,        ERRwrongdisk,   NT_STATUS_WRONG_VOLUME},
        {ERRHRD,        38,     NT_STATUS_END_OF_FILE},
+#if defined(WITH_QUOTAS) && defined(EDQUOT)
+       {ERRHRD,        ERRdiskfull,    NT_STATUS_QUOTA_EXCEEDED},
+#else
        {ERRHRD,        ERRdiskfull,    NT_STATUS_DISK_FULL},
+#endif
        {ERRHRD,        50,     NT_STATUS_CTL_FILE_NOT_SUPPORTED},
        {ERRHRD,        51,     NT_STATUS_REMOTE_NOT_LISTENING},
        {ERRHRD,        52,     NT_STATUS_DUPLICATE_NAME},
@@ -1522,7 +1526,7 @@
        { EISDIR, ERRDOS, ERRnoaccess, NT_STATUS_FILE_IS_A_DIRECTORY},
        { EMLINK, ERRDOS, ERRgeneral, NT_STATUS_TOO_MANY_LINKS },
 #ifdef EDQUOT
-       { EDQUOT, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL },
+       { EDQUOT, ERRHRD, ERRdiskfull, NT_STATUS_QUOTA_EXCEEDED },
 #endif
 #ifdef ENOTEMPTY
        { ENOTEMPTY, ERRDOS, ERRnoaccess, NT_STATUS_DIRECTORY_NOT_EMPTY },
@@ -1539,6 +1543,9 @@
 #ifdef EFBIG
        { EFBIG, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL },
 #endif
+#ifdef ENOBUFS
+       { ENOBUFS, ERRDOS, ERRnomem, NT_STATUS_INSUFFICIENT_RESOURCES },
+#endif
        { 0, 0, 0, NT_STATUS_OK }
 };
 

Modified: branches/tmp/vl-messaging/source/passdb/pdb_smbpasswd.c
===================================================================
--- branches/tmp/vl-messaging/source/passdb/pdb_smbpasswd.c     2006-07-26 
06:18:13 UTC (rev 17251)
+++ branches/tmp/vl-messaging/source/passdb/pdb_smbpasswd.c     2006-07-26 
06:59:50 UTC (rev 17252)
@@ -1192,6 +1192,7 @@
                              struct samu *sam_pass, const struct smb_passwd 
*pw_buf)
 {
        struct passwd *pwfile;
+       fstring unix_username;
        
        if ( !sam_pass ) {
                DEBUG(5,("build_sam_account: struct samu is NULL\n"));
@@ -1199,8 +1200,11 @@
        }
 
        /* verify the user account exists */
+
+       fstrcpy( unix_username, pw_buf->smb_name );
+       strlower_m( unix_username );
                        
-       if ( !(pwfile = getpwnam_alloc(NULL, pw_buf->smb_name)) ) {
+       if ( !(pwfile = getpwnam_alloc(NULL, unix_username )) ) {
                DEBUG(0,("build_sam_account: smbpasswd database is corrupt!  
username %s with uid "
                "%u is not in unix passwd database!\n", pw_buf->smb_name, 
pw_buf->smb_userid));
                        return False;

Modified: branches/tmp/vl-messaging/source/rpc_server/srv_spoolss_nt.c
===================================================================
--- branches/tmp/vl-messaging/source/rpc_server/srv_spoolss_nt.c        
2006-07-26 06:18:13 UTC (rev 17251)
+++ branches/tmp/vl-messaging/source/rpc_server/srv_spoolss_nt.c        
2006-07-26 06:59:50 UTC (rev 17252)
@@ -441,7 +441,7 @@
        const char *servername;
        fstring sname;
        BOOL found=False;
-       NT_PRINTER_INFO_LEVEL *printer;
+       NT_PRINTER_INFO_LEVEL *printer = NULL;
        WERROR result;
        
        DEBUG(4,("Setting printer name=%s (len=%lu)\n", handlename, (unsigned 
long)strlen(handlename)));
@@ -532,6 +532,7 @@
                printername++;
                
                if ( strequal(printername, aprinter) ) {
+                       free_a_printer( &printer, 2);
                        found = True;
                        break;
                }
@@ -541,6 +542,8 @@
                free_a_printer( &printer, 2);
        }
 
+       free_a_printer( &printer, 2);
+
        if ( !found ) {
                DEBUGADD(4,("Printer not found\n"));
                return False;
@@ -3551,6 +3554,7 @@
 
                if((info->data=SMB_REALLOC_ARRAY(info->data, 
SPOOL_NOTIFY_INFO_DATA, info->count+1)) == NULL) {
                        DEBUG(2,("construct_notify_printer_info: failed to 
enlarge buffer info->data!\n"));
+                       free_a_printer(&printer, 2);
                        return False;
                }
 
@@ -4181,6 +4185,7 @@
        *pp_printer = NULL;
        if ((printer = SMB_MALLOC_P(PRINTER_INFO_3)) == NULL) {
                DEBUG(2,("construct_printer_info_3: malloc fail.\n"));
+               free_a_printer(&ntprinter, 2);
                return False;
        }
 
@@ -4983,8 +4988,10 @@
        if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, 
lp_const_servicename(snum))))
                return WERR_INVALID_PRINTER_NAME;
 
-       if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, 
printer->info_2->drivername, architecture, version)))
+       if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, 
printer->info_2->drivername, architecture, version))) {
+               free_a_printer(&printer, 2);
                return WERR_UNKNOWN_PRINTER_DRIVER;
+       }
 
        fill_printer_driver_info_1(info, driver, servername, architecture);
 
@@ -5043,8 +5050,10 @@
        if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, 
lp_const_servicename(snum))))
                return WERR_INVALID_PRINTER_NAME;
 
-       if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, 
printer->info_2->drivername, architecture, version)))
+       if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, 
printer->info_2->drivername, architecture, version))) {
+               free_a_printer(&printer, 2);
                return WERR_UNKNOWN_PRINTER_DRIVER;
+       }
 
        fill_printer_driver_info_2(info, driver, servername);
 
@@ -6386,9 +6395,9 @@
 /****************************************************************************
 ****************************************************************************/
 
-static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue,
+static void fill_job_info_1(JOB_INFO_1 *job_info, const print_queue_struct 
*queue,
                             int position, int snum, 
-                            NT_PRINTER_INFO_LEVEL *ntprinter)
+                            const NT_PRINTER_INFO_LEVEL *ntprinter)
 {
        struct tm *t;
        
@@ -6413,9 +6422,9 @@
 /****************************************************************************
 ****************************************************************************/
 
-static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue,
+static BOOL fill_job_info_2(JOB_INFO_2 *job_info, const print_queue_struct 
*queue,
                             int position, int snum, 
-                           NT_PRINTER_INFO_LEVEL *ntprinter,
+                           const NT_PRINTER_INFO_LEVEL *ntprinter,
                            DEVICEMODE *devmode)
 {
        struct tm *t;
@@ -6458,8 +6467,8 @@
  Enumjobs at level 1.
 ****************************************************************************/
 
-static WERROR enumjobs_level1(print_queue_struct *queue, int snum,
-                              NT_PRINTER_INFO_LEVEL *ntprinter,
+static WERROR enumjobs_level1(const print_queue_struct *queue, int snum,
+                              const NT_PRINTER_INFO_LEVEL *ntprinter,
                              RPC_BUFFER *buffer, uint32 offered,
                              uint32 *needed, uint32 *returned)
 {
@@ -6469,7 +6478,6 @@
        
        info=SMB_MALLOC_ARRAY(JOB_INFO_1,*returned);
        if (info==NULL) {
-               SAFE_FREE(queue);
                *returned=0;
                return WERR_NOMEM;
        }
@@ -6477,8 +6485,6 @@
        for (i=0; i<*returned; i++)
                fill_job_info_1( &info[i], &queue[i], i, snum, ntprinter );
 
-       SAFE_FREE(queue);
-
        /* check the required size. */  
        for (i=0; i<*returned; i++)
                (*needed) += spoolss_size_job_info_1(&info[i]);
@@ -6511,8 +6517,8 @@
  Enumjobs at level 2.
 ****************************************************************************/
 
-static WERROR enumjobs_level2(print_queue_struct *queue, int snum,
-                              NT_PRINTER_INFO_LEVEL *ntprinter,
+static WERROR enumjobs_level2(const print_queue_struct *queue, int snum,
+                              const NT_PRINTER_INFO_LEVEL *ntprinter,
                              RPC_BUFFER *buffer, uint32 offered,
                              uint32 *needed, uint32 *returned)
 {
@@ -6533,9 +6539,6 @@
        for (i=0; i<*returned; i++)
                fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter, 
devmode);
 
-       free_a_printer(&ntprinter, 2);
-       SAFE_FREE(queue);
-
        /* check the required size. */  
        for (i=0; i<*returned; i++)
                (*needed) += spoolss_size_job_info_2(&info[i]);
@@ -6611,22 +6614,24 @@
 
        if (*returned == 0) {
                SAFE_FREE(queue);
+               free_a_printer(&ntprinter, 2);
                return WERR_OK;
        }
 
        switch (level) {
        case 1:
                wret = enumjobs_level1(queue, snum, ntprinter, buffer, offered, 
needed, returned);
-               return wret;
+               break;
        case 2:
                wret = enumjobs_level2(queue, snum, ntprinter, buffer, offered, 
needed, returned);
-               return wret;
+               break;
        default:
-               SAFE_FREE(queue);
                *returned=0;
                wret = WERR_UNKNOWN_LEVEL;
+               break;
        }
        
+       SAFE_FREE(queue);
        free_a_printer( &ntprinter, 2 );
        return wret;
 }

Modified: branches/tmp/vl-messaging/source/smbd/open.c
===================================================================
--- branches/tmp/vl-messaging/source/smbd/open.c        2006-07-26 06:18:13 UTC 
(rev 17251)
+++ branches/tmp/vl-messaging/source/smbd/open.c        2006-07-26 06:59:50 UTC 
(rev 17252)
@@ -1212,14 +1212,12 @@
                        /* If file exists replace/overwrite. If file doesn't
                         * exist create. */
                        flags2 |= (O_CREAT | O_TRUNC);
-                       open_access_mask |= FILE_WRITE_DATA; /* This will cause 
oplock breaks. */
                        break;
 
                case FILE_OVERWRITE_IF:
                        /* If file exists replace/overwrite. If file doesn't
                         * exist create. */
                        flags2 |= (O_CREAT | O_TRUNC);
-                       open_access_mask |= FILE_WRITE_DATA; /* This will cause 
oplock breaks. */
                        break;
 
                case FILE_OPEN:
@@ -1244,7 +1242,6 @@
                                return NT_STATUS_OBJECT_NAME_NOT_FOUND;
                        }
                        flags2 |= O_TRUNC;
-                       open_access_mask |= FILE_WRITE_DATA; /* This will cause 
oplock breaks. */
                        break;
 
                case FILE_CREATE:
@@ -1297,9 +1294,6 @@
        /* This is a nasty hack - must fix... JRA. */
        if (access_mask == MAXIMUM_ALLOWED_ACCESS) {
                open_access_mask = access_mask = FILE_GENERIC_ALL;
-               if (flags2 & O_TRUNC) {
-                       open_access_mask |= FILE_WRITE_DATA; /* This will cause 
oplock breaks. */
-               }
        }
 
        /*
@@ -1307,7 +1301,12 @@
         */
 
        se_map_generic(&access_mask, &file_generic_mapping);
+       open_access_mask = access_mask;
 
+       if (flags2 & O_TRUNC) {
+               open_access_mask |= FILE_WRITE_DATA; /* This will cause oplock 
breaks. */
+       }
+
        DEBUG(10, ("open_file_ntcreate: fname=%s, after mapping "
                   "access_mask=0x%x\n", fname, access_mask ));
 
@@ -1548,9 +1547,11 @@
                unx_mode = 0777;
        }
 
-       DEBUG(4,("calling open_file with flags=0x%X flags2=0x%X mode=0%o\n",
+       DEBUG(4,("calling open_file with flags=0x%X flags2=0x%X mode=0%o, "
+               "access_mask = 0x%x, open_access_mask = 0x%x\n",
                 (unsigned int)flags, (unsigned int)flags2,
-                (unsigned int)unx_mode));
+                (unsigned int)unx_mode, (unsigned int)access_mask,
+                (unsigned int)open_access_mask));
 
        /*
         * open_file strips any O_TRUNC flags itself.

Reply via email to