aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2011-09-26 18:20:06 -0700
committerH. Peter Anvin <hpa@zytor.com>2011-09-26 18:20:06 -0700
commit0f42fdd6c25b8a95301c9a827dae048cb0165e5f (patch)
treedb37bbf2da9e8b153b5e74aa359312e49f47129d
parent4d3bb80bfceb3775213cbb0189abcb4588228b18 (diff)
downloadkup-0f42fdd6c25b8a95301c9a827dae048cb0165e5f.tar.gz
Fix sysopen for write, fix exec, add DONE command
Fix sysopen() arguments for writing. Fix exec() arguments. Add a DONE command for the cases where it's hard to tell if a file is ended.
-rwxr-xr-xkorg-upload10
1 files changed, 7 insertions, 3 deletions
diff --git a/korg-upload b/korg-upload
index d38d447..22ec9cd 100755
--- a/korg-upload
+++ b/korg-upload
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -T
+#!/usr/bin/perl
#
# This script should be run with the permissions of the user that
# is uploading files.
@@ -21,6 +21,8 @@
# - creates a new directory
# MOVE old-path:new-path
# - moves <old-path> to <new-path>
+# DONE
+# - optional command, terminates transaction
#
# For future consideration:
#
@@ -352,7 +354,7 @@ sub make_compressed_data()
if ($w == 0) {
sysopen(RAW, $tmpdir.'/data', O_RDONLY)
or exit 127;
- sysopen(OUT, $tmpdir.'/data'.$e, O_WRONLY, 0002)
+ sysopen(OUT, $tmpdir.'/data'.$e, O_WRONLY|O_CREAT|O_TRUNC, 0666)
or exit 127;
open(STDIN, '<&', \*RAW) or exit 127;
@@ -360,7 +362,7 @@ sub make_compressed_data()
close(RAW);
close(OUT);
- exec(@c);
+ exec {$c[0]} @c;
exit 127;
}
@@ -570,6 +572,8 @@ while (defined($line = <STDIN>)) {
do_mkdir(@args);
} elsif ($cmd eq 'MOVE') {
move_file(@args);
+ } elsif ($cmd eq 'DONE') {
+ last;
} else {
die "400 Invalid command\n";
exit 1;