summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alex@spline.inf.fu-berlin.de>2016-06-21 03:10:13 +0200
committerAlexander Sulfrian <alex@spline.inf.fu-berlin.de>2016-06-21 03:10:13 +0200
commitea57f7b2b7b295a06c6cb361f5c1e61f78e7b456 (patch)
tree422f3c018ce47b0ed1fa8278c4a572b978cd34b8
parent339312c92a71a0943ae34aab27b1026bb3479d0d (diff)
downloadsrs-ea57f7b2b7b295a06c6cb361f5c1e61f78e7b456.tar.gz
srs-ea57f7b2b7b295a06c6cb361f5c1e61f78e7b456.tar.bz2
srs-ea57f7b2b7b295a06c6cb361f5c1e61f78e7b456.zip
Allow ~ in secret_file path
-rw-r--r--Spline/Socketmap/Srs.pm12
1 files changed, 10 insertions, 2 deletions
diff --git a/Spline/Socketmap/Srs.pm b/Spline/Socketmap/Srs.pm
index 5917c00..c4a9623 100644
--- a/Spline/Socketmap/Srs.pm
+++ b/Spline/Socketmap/Srs.pm
@@ -54,7 +54,15 @@ sub post_configure_hook {
# secrets
my @secrets = ();
if (defined $prop->{secret_file}) {
- if (open(my $file, '<', $prop->{secret_file})) {
+ my $filename = $prop->{secret_file};
+ # Replace ~ and ~user:
+ $filename =~ s{^~([^/]*)}{
+ $1
+ ? (getpwnam($1))[7]
+ : (getpwuid($<))[7]
+ }ex;
+
+ if (open(my $file, '<', $filename)) {
while (<$file>) {
chomp;
push @secrets, $_;
@@ -62,7 +70,7 @@ sub post_configure_hook {
close($file);
}
else {
- $self->log(1, 'ERROR: Cannot open secret_file: "' . $prop->{secret_file} . '"');
+ $self->log(1, 'ERROR: Cannot open secret_file: "' . $filename . '"');
}
}