]> git.ameliathe1st.gay Git - git-over-gnunet.git/commitdiff
Prepare to add pushing (protected by gnunet-identity)
authorAmélia Coutard-Sander <git@ameliathe1st.gay>
Wed, 4 Dec 2024 23:41:45 +0000 (00:41 +0100)
committerAmélia Coutard-Sander <git@ameliathe1st.gay>
Wed, 4 Dec 2024 23:41:45 +0000 (00:41 +0100)
git-remote-gnunet
handle-request.sh

index 796a88c598f54fd3d0032614e1170991aeeeaa92..edccd4952a7e870433bfcc53edc5deb36906b48b 100755 (executable)
@@ -14,6 +14,7 @@ if test "$?" != "0"; then
        echo >&2 "URI format: \`[gnunet://][user@]gns.name[/path/to/repo]'."
        exit 1
 fi
+pkey="$(gnunet-identity -qde "$username")"
 
 while read -r cmd arg; do
        case "$cmd" in
@@ -42,4 +43,4 @@ echo >&2 "Trying service \`$service' on peer \`$peer'."
 ip="$(gnunet-vpn -s "$service" -p "$peer" -t)"
 echo >&2 "Using tunnel ip \`$ip'."
 
-{ printf '%s\n' "$path" "$arg"; cat; } | socat stdio tcp4:"$ip":9418
+{ printf '%s\n' "$path" "$arg" "$pkey"; cat; } | socat stdio tcp4:"$ip":9418
index 743a99e048529e7c62d3143a2edc02b7643ab5f2..4894910df6850e236f9a05529e8fe1067c5f7ecb 100755 (executable)
@@ -8,20 +8,31 @@ base_path="$1"
 
 read -r path || { echo "No path specified." | tee /dev/stderr; exit 1; }
 read -r comm || { echo "No command specified." | tee /dev/stderr; exit 1; }
+read -r pkey || { echo "No pkey specified." | tee /dev/stderr; exit 1; }
 
 full_path="$(realpath -sm "$base_path$path")"
 case "$full_path" in
-       "$base_path") ;;
-       "$base_path/"*) ;;
-       *)      echo "Invalid path: \`$full_path'." | tee /dev/stderr
-               exit 1
-               ;;
+"$base_path") ;;
+"$base_path/"*) ;;
+*)     echo "Invalid path: \`$full_path'." | tee /dev/stderr
+       exit 1
+       ;;
 esac
 
-if test "$comm" != "git-upload-pack"; then
-       echo "Command \`$comm' has to be git-upload-pack." | tee /dev/stderr
+case "$comm" in
+git-upload-pack)
+       # No pkey checking.
+       ;;
+git-receive-pack)
+       # Accept any valid pkey. FIXME
+       echo "Command \`$comm' not supported yet." | tee /dev/stderr
        exit 1
-fi
+       ;;
+*)
+       echo "Unknown command: \`$comm'." | tee /dev/stderr
+       exit 1
+       ;;
+esac
 
 git_dir="$(git -C "$full_path" rev-parse --path-format=absolute --git-dir)" || { echo "Not a git repository: \`$full_path'." | tee /dev/stderr; exit 1; }