Bug fixes to ntcoin

1. Single quotes closed before command substitutions, and opened again right after them. (Some cases were missed previously.)
2. The u+s mode/permission is used on all subdirectories of the tcoin directory and the tcoin directory itself now, so that files created are owned by the owner of the containing directory by default. This will prevent the class of bugs that would arise when files are created through the tcoin executable (which has the setuid bit set).
3. A mistake in the file name and location of the base amount (tcoin/base/base.txt) was corrected.
This commit is contained in:
~login@aussies.space 2019-09-30 14:58:06 +00:00
parent a3c2369785
commit ff3805d309
1 changed files with 28 additions and 19 deletions

47
ntcoin
View File

@ -30,6 +30,7 @@ else
else
/bin/mkdir "`/usr/bin/realpath -s $1`/tcoin"
/bin/chmod 700 "`/usr/bin/realpath -s $1`/tcoin"
/bin/chmod u+s "`/usr/bin/realpath -s $1`/tcoin"
fi
if [ -d "`/usr/bin/realpath -s $1`/tcoin/salts" ]
then
@ -38,6 +39,7 @@ else
else
/bin/mkdir "`/usr/bin/realpath -s $1`/tcoin/salts"
/bin/chmod 700 "`/usr/bin/realpath -s $1`/tcoin/salts"
/bin/chmod u+s "`/usr/bin/realpath -s $1`/tcoin/salts"
fi
if [ -d "`/usr/bin/realpath -s $1`/tcoin/passwords" ]
then
@ -46,6 +48,7 @@ else
else
/bin/mkdir "`/usr/bin/realpath -s $1`/tcoin/passwords"
/bin/chmod 700 "`/usr/bin/realpath -s $1`/tcoin/passwords"
/bin/chmod u+s "`/usr/bin/realpath -s $1`/tcoin/passwords"
fi
if [ -d "`/usr/bin/realpath -s $1`/tcoin/program_accounting" ]
then
@ -54,6 +57,7 @@ else
else
/bin/mkdir "`/usr/bin/realpath -s $1`/tcoin/program_accounting"
/bin/chmod 700 "`/usr/bin/realpath -s $1`/tcoin/program_accounting"
/bin/chmod u+s "`/usr/bin/realpath -s $1`/tcoin/program_accounting"
fi
if [ -d "`/usr/bin/realpath -s $1`/tcoin/messages" ]
then
@ -62,6 +66,7 @@ else
else
/bin/mkdir "`/usr/bin/realpath -s $1`/tcoin/messages"
/bin/chmod 700 "`/usr/bin/realpath -s $1`/tcoin/messages"
/bin/chmod u+s "`/usr/bin/realpath -s $1`/tcoin/messages"
fi
if [ -d "`/usr/bin/realpath -s $1`/tcoin/base" ]
then
@ -70,12 +75,13 @@ else
else
/bin/mkdir "`/usr/bin/realpath -s $1`/tcoin/base"
/bin/chmod 700 "`/usr/bin/realpath -s $1`/tcoin/base"
/bin/chmod u+s "`/usr/bin/realpath -s $1`/tcoin/base"
if [ -e "`/usr/bin/realpath -s $1`/tcoin/base/base.txt" ]
then
/bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/base/base.txt' already exists."
exit 1
else
/bin/echo "$2" > "./tcoin/$2.txt"
/bin/echo "$2""00" > "`/usr/bin/realpath -s $1`/tcoin/base/base.txt"
/bin/chmod 600 "`/usr/bin/realpath -s $1`/tcoin/base/base.txt"
fi
fi
@ -86,6 +92,7 @@ else
else
/bin/mkdir "`/usr/bin/realpath -s $1`/tcoin/secrets"
/bin/chmod 700 "`/usr/bin/realpath -s $1`/tcoin/secrets"
/bin/chmod u+s "`/usr/bin/realpath -s $1`/tcoin/secrets"
if [ -e "`/usr/bin/realpath -s $1`/tcoin/secrets/pcoin_keys" ]
then
/bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/secrets/pcoin_keys' already exists."
@ -110,6 +117,7 @@ else
else
/bin/mkdir "`/usr/bin/realpath -s $1`/tcoin/bin"
/bin/chmod 700 "`/usr/bin/realpath -s $1`/tcoin/bin"
/bin/chmod u+s "`/usr/bin/realpath -s $1`/tcoin/bin"
if [ -e "`/usr/bin/realpath -s $1`/tcoin/bin/scrypt" ]
then
/bin/echo "Sorry, '`/usr/bin/realpath -s $1`/tcoin/bin/scrypt' already exists."
@ -124,9 +132,9 @@ else
exit 1
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"
(/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 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"
@ -140,9 +148,9 @@ else
exit 1
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"
(/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 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"
@ -152,16 +160,17 @@ else
fi
fi
/bin/echo "Printing tcoin.cpp (and pcoin.cpp) preprocessor directives."
/bin/echo "Paste the following after the #includes inside tcoin.cpp (and pcoin.cpp):"
/bin/echo '#define TCOIN_PATH "`/usr/bin/realpath -s $1`/tcoin"
#define TCOIN_MSG_PATH "`/usr/bin/realpath -s $1`/tcoin/messages/"
#define TCOIN_SALT_PATH "`/usr/bin/realpath -s $1`/tcoin/salts/"
#define TCOIN_PASS_PATH "`/usr/bin/realpath -s $1`/tcoin/passwords/"
#define TCOIN_PROG_ACT_PATH "`/usr/bin/realpath -s $1`/tcoin/program_accounting/"
/bin/echo "Paste the following after the #includes inside tcoin.cpp (and pcoin.cpp):
"
/bin/echo '#define TCOIN_PATH "'`/usr/bin/realpath -s $1`'/tcoin"
#define TCOIN_MSG_PATH "'`/usr/bin/realpath -s $1`'/tcoin/messages/"
#define TCOIN_SALT_PATH "'`/usr/bin/realpath -s $1`'/tcoin/salts/"
#define TCOIN_PASS_PATH "'`/usr/bin/realpath -s $1`'/tcoin/passwords/"
#define TCOIN_PROG_ACT_PATH "'`/usr/bin/realpath -s $1`'/tcoin/program_accounting/"
#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_PATH_W_SLASH "`/usr/bin/realpath -s $1`/tcoin/"
#define TCOIN_SCRYPT_PATH "`/usr/bin/realpath -s $1`/tcoin/bin/scrypt"'
fi
#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_PATH_W_SLASH "'`/usr/bin/realpath -s $1`'/tcoin/"
#define TCOIN_SCRYPT_PATH "'`/usr/bin/realpath -s $1`'/tcoin/bin/scrypt"'
fi