Merge lp:~townsend/libertine/detect-sudo into lp:libertine

Proposed by Christopher Townsend
Status: Merged
Approved by: Larry Price
Approved revision: 205
Merged at revision: 204
Proposed branch: lp:~townsend/libertine/detect-sudo
Merge into: lp:libertine
Diff against target: 38 lines (+13/-0)
2 files modified
libertine/main.cpp (+8/-0)
tools/libertine-container-manager (+5/-0)
To merge this branch: bzr merge lp:~townsend/libertine/detect-sudo
Reviewer Review Type Date Requested Status
Larry Price Approve
Libertine CI Bot continuous-integration Approve
Review via email: mp+292027@code.launchpad.net

Commit message

Check to see if libertine-container-manager is ran using sudo and if so, print a message and exit.

To post a comment you must log in.
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

As Larry pointed out, running the libertine GUI via sudo has some consequences as well, so I should put in something in libertine to exit if it's invoked via sudo.

Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Larry Price (larryprice) wrote :

Looks good, blocks me from running as sudo as stated.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libertine/main.cpp'
2--- libertine/main.cpp 2015-05-13 13:42:12 +0000
3+++ libertine/main.cpp 2016-04-18 13:56:57 +0000
4@@ -19,10 +19,18 @@
5 #include "libertine/config.h"
6 #include "libertine/libertine.h"
7
8+#include <unistd.h>
9+#include <QtCore/QDebug>
10
11 int
12 main(int argc, char* argv[])
13 {
14+ if (!geteuid())
15+ {
16+ qWarning() << "Please do not run " LIBERTINE_APPLICATION_NAME " using \'sudo\'.";
17+ exit(1);
18+ }
19+
20 Libertine app(argc, argv);
21 return app.exec();
22 }
23
24=== modified file 'tools/libertine-container-manager'
25--- tools/libertine-container-manager 2016-04-14 17:05:21 +0000
26+++ tools/libertine-container-manager 2016-04-18 13:56:57 +0000
27@@ -531,6 +531,11 @@
28
29 if __name__ == '__main__':
30 parser = argparse.ArgumentParser(description="Legacy X application support for Unity 8")
31+
32+ if not os.geteuid():
33+ print("Please do not run %s using sudo" % parser.prog)
34+ sys.exit(1)
35+
36 parser.add_argument('-q', '--quiet',
37 action='store_const', dest='verbosity', const=0,
38 help=('do not print status updates on stdout'))

Subscribers

People subscribed via source and target branches