summaryrefslogtreecommitdiffstats
path: root/src/sudo.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2007-12-06 00:29:52 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2007-12-06 00:29:52 +0100
commitf51aa191c2be32b989b4ddb5fee31b8bfd75edf5 (patch)
treebfaf4e746da8d6bd071af09d4d0e5a0ad6a56884 /src/sudo.c
parent980ff85c3050ff15bf8e473ead40c24dba4b4353 (diff)
"testdisk -lu device" will list the partition with sector unit
Diffstat (limited to 'src/sudo.c')
-rw-r--r--src/sudo.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/sudo.c b/src/sudo.c
new file mode 100644
index 0000000..88b371e
--- /dev/null
+++ b/src/sudo.c
@@ -0,0 +1,61 @@
+/*
+
+ File: sudo.c
+
+ Copyright (C) 2007 Christophe GRENIER <grenier@cgsecurity.org>
+
+ This software 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 the Free Software Foundation, Inc., 51
+ Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef SUDO_BIN
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h> /* execv */
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#include <stdio.h>
+#include <errno.h>
+#include "types.h"
+#include "common.h"
+#include "sudo.h"
+
+void run_sudo(int argc, char **argv)
+{
+ int i;
+ char **argv2;
+ argv2 = (char **)MALLOC(sizeof(char *) * (argc + 2));
+ argv2[0]=SUDO_BIN;
+ for (i=0; i < argc; i++)
+ argv2[i+1] = argv[i];
+ argv2[i+1]=NULL;
+ printf("sudo may ask your user password\n");
+ fflush(stdout);
+ if(execv(argv2[0], argv2)<0)
+ {
+ printf("%s failed: %s\n", SUDO_BIN, strerror(errno));
+ printf("Press Enter key to quit.\n");
+ getchar();
+ }
+ free(argv2);
+}
+#endif