diff --git a/ChangeLog.txt b/ChangeLog.txt index 185d0ebe..b4283ffc 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +2.9.5 - 26/09/2015 +Updated: +- Check for root privileges + 2.9.4 - 24/09/2015 Updated: - KeyboardInterrupt for main.py diff --git a/bin/slpkg b/bin/slpkg index 60d6c35b..b2b52dae 100755 --- a/bin/slpkg +++ b/bin/slpkg @@ -33,10 +33,11 @@ Slpkg is a user-friendly package manager for Slackware installations """ from slpkg.main import main - +from slpkg.superuser import s_user if __name__ == "__main__": try: + s_user() main() except KeyboardInterrupt: print("") diff --git a/slpkg/__metadata__.py b/slpkg/__metadata__.py index 78d149bd..e012cd14 100644 --- a/slpkg/__metadata__.py +++ b/slpkg/__metadata__.py @@ -23,16 +23,6 @@ import os -import getpass - - -def s_user(user): - """ - Check for root user - """ - if user != "root": - print("\nslpkg: Error: Must have root privileges\n") - raise SystemExit() def remove_repositories(repositories, default_repositories): @@ -92,8 +82,6 @@ class MetaData(object): __license__ = "GNU General Public License v3 (GPLv3)" __email__ = "d.zlatanidis@gmail.com" - s_user(getpass.getuser()) - # Default Slackware release slack_rel = "stable" diff --git a/slpkg/main.py b/slpkg/main.py index cff43755..0230ae4a 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -24,7 +24,6 @@ import os import sys -import getpass from slpkg.load import Regex from slpkg.desc import PkgDesc @@ -688,7 +687,6 @@ class ArgParse(object): def main(): - Msg().s_user(getpass.getuser()) args = sys.argv args.pop(0) diff --git a/slpkg/messages.py b/slpkg/messages.py index b8ac69d4..ec67c636 100644 --- a/slpkg/messages.py +++ b/slpkg/messages.py @@ -49,13 +49,6 @@ class Msg(object): """ print("| Package {0} installed".format(pkg)) - def s_user(self, user): - """Check for root user - """ - if user != "root": - print("\nslpkg: Error: Must have root privileges\n") - raise SystemExit() - def build_FAILED(self, prgnam): """Print error message if build failed """ diff --git a/slpkg/superuser.py b/slpkg/superuser.py new file mode 100644 index 00000000..0216006c --- /dev/null +++ b/slpkg/superuser.py @@ -0,0 +1,33 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# superuser.py file is part of slpkg. + +# Copyright 2014-2015 Dimitris Zlatanidis +# All rights reserved. + +# Slpkg is a user-friendly package manager for Slackware installations + +# https://github.com/dslackw/slpkg + +# Slpkg is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +import getpass + + +def s_user(): + """Check for root user + """ + if getpass.getuser() != "root": + print("\nslpkg: Error: Must have root privileges\n") + raise SystemExit()