about summary refs log tree commit diff stats
path: root/ntcoin
diff options
context:
space:
mode:
author~login@aussies.space <login@aussies.space>2019-10-03 04:08:42 +0000
committer~login@aussies.space <login@aussies.space>2019-10-03 04:08:42 +0000
commit6825e86a248df58e4248e1047e412bd4b7e2795a (patch)
tree33693addc088486ef1990785a1a075fc8439a63b /ntcoin
parent4d21a73f72f2d62b318c217e76e84ff92a9dc36c (diff)
downloadtcoin-6825e86a248df58e4248e1047e412bd4b7e2795a.tar.gz
Bug fix to ntcoin
Previously, the executables 'tcoin' and 'pcoin', which had setuid set, were stored in tcoin/bin/*. However, the "tcoin" directory is restricted, so any executables inside it are inaccessible to users.

To fix this, the compile_tcoin and compile_pcoin scripts have been modified to store the executables in a third specified directory, called the <bin dir> in the help. <bin dir> will be accessible to all users. The symbolic constants/preprocessor directives have also been changed to reflect the updated paths.
Diffstat (limited to 'ntcoin')
-rwxr-xr-xntcoin30
1 files changed, 19 insertions, 11 deletions
diff --git a/ntcoin b/ntcoin
index 71e09f5..051fd9c 100755
--- a/ntcoin
+++ b/ntcoin
@@ -3,8 +3,8 @@
 if [ "$#" -eq 0 ] || [ "$1" = "--help" ] || [ "$1" = "-h" ]
 then
   /bin/echo "Usage:"
-  /bin/echo "  ntcoin <path (no slash)> <n> : to create tcoin subdirectories in <path (no slash)> with <n> basecoins per user"
-  /bin/echo "  ntcoin <path (no slash)> [ --def | -d ] : to print only the #define preprocessor directives without creating any directories"
+  /bin/echo "  ntcoin <path (no slash)> <bin path (no slash)> <n> : to create tcoin subdirectories in <path (no slash)> with the executable saved to <bin path (no slash)> and with <n> basecoins per user"
+  /bin/echo "  ntcoin <path (no slash)> <bin path (no slash)> [ --def | -d ]: to print only the #define preprocessor directives without creating any directories"
   /bin/echo "  ntcoin [ --help | -h ] : to print this help"
 elif [ "$2" = "--def" ] || [ "$2" = "-d" ]
 then
@@ -19,11 +19,11 @@ then
 #define PROG_ACT_W_SLASH "program_accounting/"
 #define PCOIN_KEY_PATH "'`/usr/bin/realpath -s $1`'/tcoin/secrets/pcoin_keys"
 #define TCOIN_CODEZ_PATH "'`/usr/bin/realpath -s $1`'/tcoin/secrets/tcoin_codez"
-#define TCOIN_BIN_PATH_W_SPACE "'`/usr/bin/realpath -s $1`'/tcoin/bin/tcoin "
+#define TCOIN_BIN_PATH_W_SPACE "'`/usr/bin/realpath -s $2`'/tcoin "
 #define TCOIN_PATH_W_SLASH "'`/usr/bin/realpath -s $1`'/tcoin/"
 #define TCOIN_SCRYPT_PATH "'`/usr/bin/realpath -s $1`'/tcoin/bin/scrypt"
-#define PCOIN_BIN_PATH "'`/usr/bin/realpath -s $1`'/tcoin/bin/pcoin"
-#define PCOIN_BIN_PATH_W_SPACE "'`/usr/bin/realpath -s $1`'/tcoin/bin/pcoin "'
+#define PCOIN_BIN_PATH "'`/usr/bin/realpath -s $2`'/pcoin"
+#define PCOIN_BIN_PATH_W_SPACE "'`/usr/bin/realpath -s $2`'/pcoin "'
 else
   if [ -d "`/usr/bin/realpath -s $1`/tcoin" ]
   then
@@ -83,7 +83,7 @@ else
       /bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/base/base.txt' already exists."
       exit 1
     else
-      /bin/echo "$2""00" > "`/usr/bin/realpath -s $1`/tcoin/base/base.txt"
+      /bin/echo "$3""00" > "`/usr/bin/realpath -s $1`/tcoin/base/base.txt"
       /bin/chmod 600 "`/usr/bin/realpath -s $1`/tcoin/base/base.txt"
     fi
   fi
@@ -136,7 +136,11 @@ else
       /bin/echo '#!/bin/bash
 (/usr/bin/g++ '`/bin/pwd`'/tcoin.cpp -o "'`/usr/bin/realpath -s $1`'/tcoin/bin/tcoin" -std=c++11) \
 && (/bin/chmod 550 "'`/usr/bin/realpath -s $1`'/tcoin/bin/tcoin") \
-&& (/bin/chmod u+s "'`/usr/bin/realpath -s $1`'/tcoin/bin/tcoin")' > "`/usr/bin/realpath -s $1`/tcoin/bin/compile_tcoin"
+&& (/bin/chmod u+s "'`/usr/bin/realpath -s $1`'/tcoin/bin/tcoin") \
+&& (/bin/chmod u+w "'`/usr/bin/realpath -s $2`'/tcoin") \
+&& (/bin/cp "'`/usr/bin/realpath -s $1`'/tcoin/bin/tcoin" "'`/usr/bin/realpath -s $2`'/tcoin") \
+&& (/bin/chmod 550 "'`/usr/bin/realpath -s $2`'/tcoin") \
+&& (/bin/chmod u+s "'`/usr/bin/realpath -s $2`'/tcoin")' > "`/usr/bin/realpath -s $1`/tcoin/bin/compile_tcoin"
       /bin/chmod 540 "`/usr/bin/realpath -s $1`/tcoin/bin/compile_tcoin"
       /bin/echo '#!/bin/bash
 /bin/nano '`/bin/pwd`'/tcoin.cpp' > "`/usr/bin/realpath -s $1`/tcoin/bin/edit_tcoin"
@@ -152,7 +156,11 @@ else
       /bin/echo '#!/bin/bash
 (/usr/bin/g++ '`/bin/pwd`'/pcoin.cpp -o "'`/usr/bin/realpath -s $1`'/tcoin/bin/pcoin" -std=c++11) \
 && (/bin/chmod 550 "'`/usr/bin/realpath -s $1`'/tcoin/bin/pcoin") \
-&& (/bin/chmod u+s "'`/usr/bin/realpath -s $1`'/tcoin/bin/pcoin")' > "`/usr/bin/realpath -s $1`/tcoin/bin/compile_pcoin"
+&& (/bin/chmod u+s "'`/usr/bin/realpath -s $1`'/tcoin/bin/pcoin")
+&& (/bin/chmod u+w "'`/usr/bin/realpath -s $2`'/pcoin") \
+&& (/bin/cp "'`/usr/bin/realpath -s $1`'/tcoin/bin/pcoin" "'`/usr/bin/realpath -s $2`'/pcoin") \
+&& (/bin/chmod 550 "'`/usr/bin/realpath -s $2`'/pcoin") \
+&& (/bin/chmod u+s "'`/usr/bin/realpath -s $2`'/pcoin")' > "`/usr/bin/realpath -s $1`/tcoin/bin/compile_pcoin"
       /bin/chmod 540 "`/usr/bin/realpath -s $1`/tcoin/bin/compile_pcoin"
       /bin/echo '#!/bin/bash
 /bin/nano '`/bin/pwd`'/pcoin.cpp' > "`/usr/bin/realpath -s $1`/tcoin/bin/edit_pcoin"
@@ -172,9 +180,9 @@ else
 #define PROG_ACT_W_SLASH "program_accounting/"
 #define PCOIN_KEY_PATH "'`/usr/bin/realpath -s $1`'/tcoin/secrets/pcoin_keys"
 #define TCOIN_CODEZ_PATH "'`/usr/bin/realpath -s $1`'/tcoin/secrets/tcoin_codez"
-#define TCOIN_BIN_PATH_W_SPACE "'`/usr/bin/realpath -s $1`'/tcoin/bin/tcoin "
+#define TCOIN_BIN_PATH_W_SPACE "'`/usr/bin/realpath -s $2`'/tcoin "
 #define TCOIN_PATH_W_SLASH "'`/usr/bin/realpath -s $1`'/tcoin/"
 #define TCOIN_SCRYPT_PATH "'`/usr/bin/realpath -s $1`'/tcoin/bin/scrypt"
-#define PCOIN_BIN_PATH "'`/usr/bin/realpath -s $1`'/tcoin/bin/pcoin"
-#define PCOIN_BIN_PATH_W_SPACE "'`/usr/bin/realpath -s $1`'/tcoin/bin/pcoin "'
+#define PCOIN_BIN_PATH "'`/usr/bin/realpath -s $2`'/pcoin"
+#define PCOIN_BIN_PATH_W_SPACE "'`/usr/bin/realpath -s $2`'/pcoin "'
 fi