From 8e30030fad3a540cab58c764ce35a857018c12de Mon Sep 17 00:00:00 2001 From: David Date: Wed, 19 Mar 2014 23:41:38 +0000 Subject: [PATCH] Created ovpnpermit project to wrap openvpn with a setuid executable. --- main.c | 35 ++++++ ovpnpermit.pro | 7 ++ ovpnpermit.pro.user | 299 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 341 insertions(+) create mode 100644 main.c create mode 100644 ovpnpermit.pro create mode 100644 ovpnpermit.pro.user diff --git a/main.c b/main.c new file mode 100644 index 0000000..0a133b2 --- /dev/null +++ b/main.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include + +// This program will execute the openvpn executable +// passing in through the command line parameters +// The purpose is to allow openvpn to be executed +// as a different user (e.g. root) + +int main (int argc, char *argv[]) { + char * const command = "openvpn"; + char ** newargv = malloc (sizeof(char*) * (argc + 1)); + int arg; + + // Transfer the arguments passed in to a new argument array + for (arg = 0; arg < argc; arg++) { + newargv[arg] = argv[arg]; + } + // Ensure the argument list is NULL terminated (for execvp) + newargv[argc] = NULL; + // Ensure the first argument matches the command + newargv[0] = command; + + // Execute the external command + //setuid (0); + execvp (command, newargv); + + // This part of the code shouldn't be reached + printf ("Error executing openvpn\n"); + + free (newargv); + return 0; +} + diff --git a/ovpnpermit.pro b/ovpnpermit.pro new file mode 100644 index 0000000..34f0471 --- /dev/null +++ b/ovpnpermit.pro @@ -0,0 +1,7 @@ +TEMPLATE = app +CONFIG += console +CONFIG -= app_bundle +CONFIG -= qt + +SOURCES += main.c + diff --git a/ovpnpermit.pro.user b/ovpnpermit.pro.user new file mode 100644 index 0000000..64ec0c7 --- /dev/null +++ b/ovpnpermit.pro.user @@ -0,0 +1,299 @@ + + + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + true + 1 + true + 0 + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + MerSDK-SailfishOS-armv7hl + MerSDK-SailfishOS-armv7hl + {d509da11-0d11-4fad-8b14-f7a950fad5bf} + 0 + 2 + 0 + + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/flypig/Documents/Development/SailfishOS/ovpnui/build-ovpnpermit-MerSDK_SailfishOS_armv7hl-Debug + true + + + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/flypig/Documents/Development/SailfishOS/ovpnui/build-ovpnpermit-MerSDK_SailfishOS_armv7hl-Release + true + + 2 + + + + true + Rpm + + Qt4ProjectManager.MerRpmBuildStep + + 1 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy By Building An RPM Package + + Qt4ProjectManager.MerArmDeployConfiguration + + + + + true + Rsync + + Qt4ProjectManager.MerRsyncDeployStep + + 1 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy By Copying Binaries + + Qt4ProjectManager.MerRSyncDeployConfiguration + + + + + true + Rpm + + Qt4ProjectManager.MerRpmDeployStep + + 1 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy As RPM Package + + Qt4ProjectManager.MerRpmDeployConfiguration + + 3 + + + true + + false + false + false + false + true + 0.01 + 10 + true + 25 + + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 1 + + ovpnpermit (on Mer Device) + + Qt4ProjectManager.MerRunConfiguration:/home/flypig/Documents/Development/SailfishOS/ovpnui/ovpnpermit/ovpnpermit.pro + + ovpnpermit.pro + + false + + 3768 + true + false + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.EnvironmentId + {551e7bc8-ec93-459f-bb3a-08a2bffda2a5} + + + ProjectExplorer.Project.Updater.FileVersion + 14 + + -- 2.25.1