]> git.sur5r.net Git - openldap/commitdiff
change socket permission syntax (to reuse function for other purposes)
authorPierangelo Masarati <ando@openldap.org>
Wed, 23 Oct 2002 14:12:01 +0000 (14:12 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 23 Oct 2002 14:12:01 +0000 (14:12 +0000)
servers/slapd/daemon.c

index f8fc27aef4e15295fe5f4779c03941d86e6d7e49..4fd8adf24025ada76de25d15ec02bfa84a5a393c 100644 (file)
@@ -334,27 +334,53 @@ static int get_url_perms(
                }
 
                if ( strncasecmp( type, LDAPI_MOD_URLEXT "=", sizeof(LDAPI_MOD_URLEXT "=") - 1 ) == 0 ) {
-                       char    *value = type + sizeof(LDAPI_MOD_URLEXT "=") - 1;
+                       char    *value = type
+                               + ( sizeof(LDAPI_MOD_URLEXT "=") - 1 );
                        mode_t  p = 0;
                        int     j;
 
-                       if ( strlen(value) != 3 ) {
-                               return LDAP_OTHER;
-                       } 
+                       switch (strlen(value)) {
+                       case 4:
+                               /* skip leading '0' */
+                               if ( value[ 0 ] != '0' ) {
+                                       return LDAP_OTHER;
+                               }
+                               value++;
 
-                       for ( j = 0; j < 3; j++ ) {
-                               static mode_t   m[ 3 ] 
-                                       = { S_IRWXU, S_IRWXG, S_IRWXO };
+                       case 3:
+                               for ( j = 0; j < 3; j++) {
+                                       int     v;
 
-                               switch ( value[ j ] ) {
-                               case 'w':
-                                       p |= m[ j ];
-                                       break;
-                               case '-':
-                                       break;
-                               default:
-                                       return LDAP_OTHER;
+                                       v = value[ j ] - '0';
+
+                                       if ( v < 0 || v > 7 ) {
+                                               return LDAP_OTHER;
+                                       }
+
+                                       p |= v << 3*(2-j);
+                               }
+                               break;
+
+                       case 10:
+                               for ( j = 1; j < 10; j++ ) {
+                                       static mode_t   m[] = { 0, 
+                                               S_IRUSR, S_IWUSR, S_IXUSR,
+                                               S_IRGRP, S_IWGRP, S_IXGRP,
+                                               S_IROTH, S_IWOTH, S_IXOTH
+                                       };
+                                       static char     c[] = "-rwxrwxrwx"; 
+
+                                       if ( value[ j ] == c[ j ] ) {
+                                               p |= m[ j ];
+       
+                                       } else if ( value[ j ] != '-' ) {
+                                               return LDAP_OTHER;
+                                       }
                                }
+                               break;
+
+                       default:
+                               return LDAP_OTHER;
                        } 
 
                        *crit = c;
@@ -1342,7 +1368,7 @@ slapd_daemon_task(
                        char *authid = NULL;
 
                        char    *dnsname = NULL;
-                       char    *peeraddr;
+                       char    *peeraddr = NULL;
 #ifdef LDAP_PF_LOCAL
                        char    peername[MAXPATHLEN + sizeof("PATH=")];
 #elif defined(LDAP_PF_INET6)