summaryrefslogtreecommitdiff
path: root/root-manager/root-manager-helper.c
blob: e199457095c00e98d10945eaf1c44cb918568050 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* Copyright (C) 1999 Red Hat Software, Inc.
 * Copyright 2001 Ximian, Inc.
 *
 * This 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <config.h>

#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <libintl.h>
#include <unistd.h>
#include <sys/types.h>
#include <gnome.h>
#include "root-manager-wrap.h"

void
userhelper_fatal_error(int signal)
{
	gtk_main_quit();
}

int
main(int argc, char* argv[])
{
	char *argv2[] = { UH_PATH, "0", NULL };
	char **argv_fake;
	int argc_fake = 2;

	int new_fd;

	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	argv_fake = g_new0 (char *, 3);
	argv_fake[0] = UH_PATH;
	argv_fake[1] = "0";

	if (!gtk_init_check(&argc_fake, &argv_fake)) {
		fprintf (stderr, _("Could not connect to X Display"));
		return -1;
	}

	new_fd = dup (STDIN_FILENO);
	if (new_fd < 0) {
		fprintf (stderr, _("Could not duplicate file descriptor"));
		return -1;
	}

	gnome_init ("root-manager-helper", VERSION, argc_fake, argv_fake);
	gdk_rgb_init ();

	signal(SIGCHLD, userhelper_fatal_error);

	userhelper_runv (UH_PATH, new_fd);

	gtk_main();

	return 0;
}