Thursday, July 16, 2015

In this function, we're getting a directory, a user or group name, and a means to determine if it's ...

In this function, we're getting a directory, a user or group name, and a means to determine if it's a user or group.

sub set_one_acl {
    my ( $dir, $name, $is_user ) =@_;
    if ( ( -e $dir ) && ( 
         ( $is_user && check_valid_user($name) ) || 
         ( !$is_user && check_valid_group( $name ) ) 
         ) ) {
        ... action occurs here
        return 1 ; 
        }
    return 0 ;
    }

The tests individually work. Could be a symbolic link, so -e instead of -d. $is_user is a boolean. check_valid_user() and check_valid_group() use getpwnam and getgrent to be sure.

I hate that big if statement, though, but think nesting all that if would be worse.

Thoughts? Suggestions? Pity?

No comments:

Post a Comment