Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proper setting of suid flag on auto-downloaded ncsvc #23

Open
benhuxley2 opened this issue Jun 16, 2014 · 0 comments
Open

proper setting of suid flag on auto-downloaded ncsvc #23

benhuxley2 opened this issue Jun 16, 2014 · 0 comments

Comments

@benhuxley2
Copy link

    * Fix permissions on ncsvc and ncui before setting suid flag.
    * Set suid flag on ncsvc and ncui so running without root works on next execution.
    * Always compile ncui (but only fail on errors if mode=ncui).

diff --git a/jvpn.pl b/jvpn.pl
index af78e60..576aab0 100755
--- a/jvpn.pl
+++ b/jvpn.pl
@@ -368,21 +368,37 @@ if (!-e "./$mode") {
        if ($res->is_success) {
                print "Done, extracting\n";
                system("unzip -o ncLinuxApp.jar ncsvc libncui.so && chmod +x ./ncsvc");
+               system("chmod go-w ./ncsvc");
+               system("chmod ug+x ./ncsvc");
+               if( $> == 0 ) {
+                       system("chmod u+s ./ncsvc");
+               } else {
+                       printf "failed to chmod +s ncsvc (not running as root), please do this manually...\n";
+               }
+               if(!-e 'wrapper.c'){
+                       printf "wrapper.c not found in ".getcwd()."\n";
+                       printf "Please copy this file from jvpn distro and try again";
+               }
+               printf "Trying to compile 'ncui'. gcc must be installed to make this possible\n";
+               system("gcc -m32 -o ncui wrapper.c -ldl  -Wall >compile.log 2>&1 && chmod +x ./ncui");
+               if (!-e "./ncui") {
+                       printf("Error: Compilation failed, please compile.log\n");
+               }
+               else {
+                       printf("ncui binary compiled\n");
+                       system("chmod go-w ./ncui");
+                       system("chmod ug+x ./ncui");
+                       if( $> == 0 ) {
+                               system("chmod u+s ./ncui");
+                       } else {
+                               printf "failed to chmod +s ncui (not running as root), please do this manually...\n";
+                       }
+               }
                if($mode eq "ncui") {
                        if(!-e 'wrapper.c'){
-                               printf "wrapper.c not found in ".getcwd()."\n";
-                               printf "Please copy this file from jvpn distro and try again";
                                exit 1;
                        }
-                       printf "Trying to compile 'ncui'. gcc must be installed to make this possible\n";
-                       system("gcc -m32 -o ncui wrapper.c -ldl  -Wall >compile.log 2>&1 && chmod +x ./ncui");
                        if (!-e "./ncui") {
-                               printf("Error: Compilation failed, please compile.log\n");
                                exit 1;
                        }
-                       else {
-                               printf("ncui binary compiled\n");
-                       }
                }
        }
        else {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant