File: disk-manager-root.in

package info (click to toggle)
disk-manager 1.0.1-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,764 kB
  • ctags: 439
  • sloc: python: 3,373; sh: 3,282; makefile: 119
file content (69 lines) | stat: -rw-r--r-- 2,506 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! @PYTHON@ @PYOPTIONS@
# -*- python -*-
# -*- coding: UTF-8 -*-
#
#  disk-manager-root : Execute disk-manager as root. If you are not
#                      already root, search for an authentification program.
#  Copyright (C) 2007 Mertens Florent <flomertens@gmail.com>
#
#  This program 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 2 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, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

import os
import sys
import gettext
from subprocess import *

sys.path.insert(0, '/usr/share/disk-manager')

from DiskManager.Fstab.FstabDialogs import dialog
from DiskManager.config import *
from DiskManager.Utility import *
from gettext import gettext as _

if __name__ == '__main__' :
    
    gettext.bindtextdomain(PACKAGE,localedir)
    gettext.textdomain(PACKAGE)
  
    if not os.getuid() == 0 :
        desktop = get_desktop()
        if desktop == "GNOME" and test_cmd("gksu") :
            auth = "gksu"
        elif desktop == "KDE" and test_cmd("kdesu") :
            auth = "kdesu"
        elif test_cmd("gksu") :
            auth = "gksu"
        elif test_cmd("kdesu") :
            auth = "kdesu"   
        else :
            dialog("error", _("No authentication program founds"), \
                _("Disk Manager need to be run as root, but I can't find\n"
                "a graphical authentication program.\n" 
                "You should install <i>gksu</i> or <i>kdesu</i>.\n" 
                "Alternatively, you can run disk-manager from "
                "the terminal with <i>su</i> or <i>sudo</i>."))
            sys.exit()
        print "INFO : Launching %s with %s..." % (PACKAGE, auth)
        os.putenv("%s_user-XAUTHORITY" % PACKAGE, os.environ["XAUTHORITY"])
        argv = [auth, "--", PACKAGE]
        argv.extend(sys.argv[1:])
        os.execvp(auth, argv)
    else :
        argv = [PACKAGE]
        argv.extend(sys.argv[1:])
        os.execvp(PACKAGE, argv)