Browse Source

Resolves: 445305
Summary: Ensure directories created by installer get the requested mode applied.

Nathan Kinder 17 years ago
parent
commit
e6a8fd3f45

+ 11 - 0
ldap/admin/src/scripts/DSCreate.pm.in

@@ -160,6 +160,7 @@ sub changeOwnerMode {
 
     my $uid = getpwnam $inf->{General}->{SuiteSpotUserID};
     my $gid = -1; # default to leave it alone
+    my $mode_string = "";
 
     if (defined($inf->{General}->{SuiteSpotGroup})) {
         $gid = getgrnam $inf->{General}->{SuiteSpotGroup};
@@ -171,6 +172,10 @@ sub changeOwnerMode {
     if ($!) {
         return ('error_chmoding_file', $it, $!);
     }
+
+    $mode_string = sprintf "%lo", $mode;
+    debug(1, "changeOwnerMode: changed mode of $it to $mode_string\n");
+
     $! = 0; # clear errno
     if ( $gidonly ) {
         chown -1, $gid, $it;
@@ -181,6 +186,12 @@ sub changeOwnerMode {
         return ('error_chowning_file', $it, $inf->{General}->{SuiteSpotUserID}, $!);
     }
 
+    if ( $gidonly ) {
+        debug(1, "changeOwnerMode: changed group ownership of $it to group $gid\n");
+    } else {
+        debug(1, "changeOwnerMode: changed ownership of $it to user $uid group $gid\n");
+    }
+
     return ();
 }
 

+ 5 - 1
ldap/admin/src/scripts/Util.pm.in

@@ -860,6 +860,7 @@ sub makePaths {
     my ($path, $mode, $user, $group) = @_;
     my $uid = getpwnam $user;
     my $gid = -1; # default to leave it alone
+    my $mode_string = "";
 
     if ($group) {
         $gid = getgrnam $group;
@@ -882,7 +883,10 @@ sub makePaths {
         if ($!) {
             return ('error_chowning_directory', $_, $!);
         }
-        debug(1, "makePaths: created directory $_ mode $mode user $user group $group\n");
+        chmod $mode, $_;
+        $mode_string = sprintf "%lo", $mode;
+        debug(1, "makePaths: created directory $_ mode $mode_string user $user group $group\n");
+        debug(2, "\t" . `ls -ld $_`);
     }
 
     return ();

+ 10 - 5
ldap/servers/slapd/snmp_collator.c

@@ -528,17 +528,22 @@ snmp_collator_create_semaphore()
         if (errno == EEXIST) {
             /* It appears that we didn't exit cleanly last time and left the semaphore
              * around.  Recreate it since we don't know what state it is in. */
-            sem_unlink(stats_sem_name);
+            if (sem_unlink(stats_sem_name) != 0) {
+                LDAPDebug( LDAP_DEBUG_ANY, "Failed to delete old semaphore for stats file (%s). "
+                          "Error %d (%s).\n", szStatsFile, errno, slapd_system_strerror(errno) );
+                exit(1);
+            }
+
             if ((stats_sem = sem_open(stats_sem_name, O_CREAT | O_EXCL, SLAPD_DEFAULT_FILE_MODE, 1)) == SEM_FAILED) {
                 /* No dice */
-                LDAPDebug( LDAP_DEBUG_ANY, "Failed to create semaphore for stats file (%s). Error %d.\n",
-                         szStatsFile, errno, 0 );
+                LDAPDebug( LDAP_DEBUG_ANY, "Failed to create semaphore for stats file (%s). Error %d (%s).\n",
+                         szStatsFile, errno, slapd_system_strerror(errno) );
                 exit(1);
             }
         } else {
             /* Some other problem occurred creating the semaphore. */
-            LDAPDebug( LDAP_DEBUG_ANY, "Failed to create semaphore for stats file (%s). Error %d.\n",
-                     szStatsFile, errno, 0 );
+            LDAPDebug( LDAP_DEBUG_ANY, "Failed to create semaphore for stats file (%s). Error %d.(%s)\n",
+                     szStatsFile, errno, slapd_system_strerror(errno) );
             exit(1);
         }
     }