- if ( strcmp( deskp->d_name, "." ) == 0 ||
- strcmp( deskp->d_name, ".." ) == 0 || strlen( deskp->d_name ) > 2 ) {
- continue;
- }
- strcpy( modbuf, deskp->d_name );
- strcat( modbuf, "/" );
- m = strchr( modbuf, '\0' );
- if (( sub = opendir( deskp->d_name )) == NULL ) {
- continue;
- }
- for ( subp = readdir( sub ); subp != NULL; subp = readdir( sub )) {
- if ( strcmp( subp->d_name, "." ) == 0 ||
- strcmp( subp->d_name, ".." ) == 0 ) {
- continue;
- }
- *m = '\0';
- strcat( modbuf, subp->d_name );
- /* XXX: need to preserve special modes */
- if (stat(modbuf, &st) < 0) {
- syslog( LOG_ERR, "setdeskmode: stat %s: %m", modbuf );
- continue;
- }
-
- if (S_ISDIR(st.st_mode)) {
- if ( chmod( modbuf, DIRBITS | mode ) < 0 ) {
- syslog( LOG_ERR, "setdeskmode: chmod %s: %m", modbuf );
- }
- } else if ( chmod( modbuf, mode ) < 0 ) {
- syslog( LOG_ERR, "setdeskmode: chmod %s: %m", modbuf );
- }
+ if ( strcmp( deskp->d_name, "." ) == 0 ||
+ strcmp( deskp->d_name, ".." ) == 0 || strlen( deskp->d_name ) > 2 ) {
+ continue;
+ }
+ strcpy( modbuf, deskp->d_name );
+ strcat( modbuf, "/" );
+ m = strchr( modbuf, '\0' );
+ if (( sub = opendir( deskp->d_name )) == NULL ) {
+ continue;
+ }
+ for ( subp = readdir( sub ); subp != NULL; subp = readdir( sub )) {
+ if ( strcmp( subp->d_name, "." ) == 0 ||
+ strcmp( subp->d_name, ".." ) == 0 ) {
+ continue;
+ }
+ *m = '\0';
+ strcat( modbuf, subp->d_name );
+ /* XXX: need to preserve special modes */
+ if (lstat(modbuf, &st) < 0) {
+ LOG(log_error, logtype_afpd, "setdeskmode: stat %s: %s",fullpathname(modbuf), strerror(errno) );
+ continue;
+ }
+
+ if (S_ISDIR(st.st_mode)) {
+ if ( chmod( modbuf, (DIRBITS | mode) & ~default_options.umask ) < 0 && errno != EPERM ) {
+ LOG(log_error, logtype_afpd, "setdeskmode: chmod %s: %s",fullpathname(modbuf), strerror(errno) );
+ }
+ } else if ( chmod( modbuf, mode & ~(default_options.umask | EXEC_MODE) ) < 0 && errno != EPERM ) {
+ LOG(log_error, logtype_afpd, "setdeskmode: chmod %s: %s",fullpathname(modbuf), strerror(errno) );
+ }