diff options
author | Daniel Kahn Gillmor <dkg@fifthhorseman.net> | 2009-08-01 17:07:29 -0400 |
---|---|---|
committer | Daniel Kahn Gillmor <dkg@fifthhorseman.net> | 2009-08-01 17:07:29 -0400 |
commit | 5822307f61fdac1888f6b16bdd2e07ab8ea193c5 (patch) | |
tree | 9f79b050d3bde16d33df4b7d8f256715056aa8b2 /src | |
parent | cb9929035b9801c5349385165cb7fdbdeb6ba735 (diff) |
cleaning up log function in checkperms for future expandability.
Diffstat (limited to 'src')
-rwxr-xr-x | src/share/checkperms | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/share/checkperms b/src/share/checkperms index 7a66b43..aa67d96 100755 --- a/src/share/checkperms +++ b/src/share/checkperms @@ -40,10 +40,17 @@ defined($path) or die "You must pass a username and an absolute path.\n"; my $pw = getpwnam($username) or die "no such user $username\n"; $path =~ m#^/# or die "path was not absolute (did not start with /)\n"; -sub debug { +sub mslog { + my $level = shift; + + # FIXME: check and compare the log level if ($ENV{LOG_LEVEL} eq 'DEBUG') { - # FIXME: prefix with $ENV{LOG_PREFIX} - printf STDERR @_; + my $format = shift; + my $out = sprintf($format, @_); + + $out =~ s/^/$ENV{LOG_PREFIX}/ ; + + printf STDERR "%s", $out; } } @@ -57,11 +64,11 @@ sub permissions_ok { while (S_ISLNK($stat->mode)) { my $newpath = realpath($path) or return "cannot trace symlink '$path'"; - debug("tracing link %s to %s\n", $path, $newpath); + mslog('DEBUG', "tracing link %s to %s\n", $path, $newpath); $path = $newpath; $stat = lstat($path) or return "cannot stat '$path'"; } - debug("checking '%s'\n", $path); + mslog('DEBUG', "checking '%s'\n", $path); if (($stat->uid != $user->uid) && ($stat->uid != 0)) { @@ -81,7 +88,7 @@ sub permissions_ok { # OpenSSH sources for an explanation of this bailout (see also # monkeysphere #675): if ($path eq $user->dir) { - debug("stopping at the %s's home directory '%s'\n", $user->name, $path); + mslog('DEBUG', "stopping at the %s's home directory '%s'\n", $user->name, $path); return undef; } |