summaryrefslogtreecommitdiff
path: root/one.cpp
diff options
context:
space:
mode:
authorGrant Limberg <glimberg@gmail.com>2015-05-16 18:55:19 -0700
committerGrant Limberg <glimberg@gmail.com>2015-05-16 18:55:19 -0700
commit9a00366b18bc2bdb3ddf4345edcc7a459eb5ed60 (patch)
treef870c3c5c4f65fc3d7e22b3b37fb96ad6eb821f9 /one.cpp
parentd0935f667fd809a32cb4184a2c422ff79dc6d933 (diff)
parent69ceb7e730a1fe4e2d0f82c7d29875bd796468ea (diff)
downloadinfinitytier-9a00366b18bc2bdb3ddf4345edcc7a459eb5ed60.tar.gz
infinitytier-9a00366b18bc2bdb3ddf4345edcc7a459eb5ed60.zip
Merge branch 'adamierymenko-dev' into android-jni
Diffstat (limited to 'one.cpp')
-rw-r--r--one.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/one.cpp b/one.cpp
index 54145d03..d6da3a26 100644
--- a/one.cpp
+++ b/one.cpp
@@ -881,6 +881,7 @@ static void printHelp(const char *cn,FILE *out)
fprintf(out,"Available switches:"ZT_EOL_S);
fprintf(out," -h - Display this help"ZT_EOL_S);
fprintf(out," -v - Show version"ZT_EOL_S);
+ fprintf(out," -U - Run as unprivileged user (skip privilege check)"ZT_EOL_S);
fprintf(out," -p<port> - Port for UDP and TCP/HTTP (default: 9993)"ZT_EOL_S);
//fprintf(out," -T<path> - Override root topology, do not authenticate or update"ZT_EOL_S);
#ifdef __UNIX_LIKE__
@@ -945,6 +946,7 @@ int main(int argc,char **argv)
std::string overrideRootTopology;
std::string homeDir;
unsigned int port = ZT1_DEFAULT_PORT;
+ bool skipRootCheck = false;
for(int i=1;i<argc;++i) {
if (argv[i][0] == '-') {
@@ -964,6 +966,10 @@ int main(int argc,char **argv)
break;
#endif // __UNIX_LIKE__
+ case 'U':
+ skipRootCheck = true;
+ break;
+
case 'T': // Override root topology
if (argv[i][2]) {
if (!OSUtils::readFile(argv[i] + 2,overrideRootTopology)) {
@@ -1082,11 +1088,10 @@ int main(int argc,char **argv)
}
#ifdef __UNIX_LIKE__
- if (getuid() != 0) {
+ if ((!skipRootCheck)&&(getuid() != 0)) {
fprintf(stderr,"%s: must be run as root (uid 0)"ZT_EOL_S,argv[0]);
return 1;
}
-
if (runAsDaemon) {
long p = (long)fork();
if (p < 0) {
@@ -1102,10 +1107,13 @@ int main(int argc,char **argv)
if (winRunFromCommandLine) {
// Running in "interactive" mode (mostly for debugging)
if (IsCurrentUserLocalAdministrator() != TRUE) {
- fprintf(stderr,"%s: must be run as a local administrator."ZT_EOL_S,argv[0]);
- return 1;
+ if (!skipRootCheck) {
+ fprintf(stderr,"%s: must be run as a local administrator."ZT_EOL_S,argv[0]);
+ return 1;
+ }
+ } else {
+ _winPokeAHole();
}
- _winPokeAHole();
SetConsoleCtrlHandler(&_winConsoleCtrlHandler,TRUE);
// continues on to ordinary command line execution code below...
} else {