summaryrefslogtreecommitdiff
path: root/src/procman_gksu.cpp
blob: 58faa0c9b576fd62e1ad01979fcb3a7294acd9dd (plain)
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
#include <config.h>

#include "procman.h"
#include "procman_gksu.h"
#include "util.h"

static gboolean (*gksu_run)(const char *, GError **);


static void load_gksu(void)
{
    static gboolean init;

    if (init)
        return;

    init = TRUE;

    load_symbols("libgksu2.so",
                 "gksu_run", &gksu_run,
                 NULL);
}





gboolean procman_gksu_create_root_password_dialog(const char *command)
{
    GError *e = NULL;

    /* Returns FALSE or TRUE on success, depends on version ... */
    gksu_run(command, &e);

    if (e) {
        g_critical("Could not run gksu_run(\"%s\") : %s\n",
                   command, e->message);
        g_error_free(e);
        return FALSE;
    }

    g_message("gksu_run did fine\n");
    return TRUE;
}



gboolean
procman_has_gksu(void)
{
    load_gksu();
    return gksu_run != NULL;
}