summaryrefslogtreecommitdiffstats
path: root/src/tdisksel.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2009-02-11 08:59:26 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2009-02-11 08:59:26 +0100
commita3677f451cf9ff1096a2c1c1247de2a276dbf26d (patch)
treef2936ed954208d3caf9b2788a9f63e1e078c3c8f /src/tdisksel.c
parented7550dea8a4d46c3227c289f39725bf911b9400 (diff)
If compiled with sudo support, add a sudo menu item for non-root user even if device list isn't empty.
Diffstat (limited to 'src/tdisksel.c')
-rw-r--r--src/tdisksel.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/tdisksel.c b/src/tdisksel.c
index fd9836d..940a2a1 100644
--- a/src/tdisksel.c
+++ b/src/tdisksel.c
@@ -66,19 +66,18 @@ static int testdisk_disk_selection_ncurses(int verbose,int dump_ind, const list_
const list_disk_t *current_disk;
static struct MenuItem menuMain[]=
{
- { 'P', "Previous",""},
- { 'N', "Next","" },
- { 'O',"Proceed",""},
- { 'Q',"Quit","Quit program"},
- { 0,NULL,NULL}
+ { 'P', "Previous", ""},
+ { 'N', "Next", "" },
+ { 'O', "Proceed", ""},
+ { 'S', "Sudo", "Use the sudo command to restart as root"},
+ { 'Q', "Quit", "Quit program"},
+ { 0, NULL, NULL}
};
if(list_disk==NULL)
{
log_critical("No disk found\n");
- use_sudo=intrf_no_disk_ncurses("TestDisk");
+ return intrf_no_disk_ncurses("TestDisk");
}
- if(list_disk==NULL || use_sudo>0)
- return use_sudo;
current_disk=list_disk;
/* ncurses interface */
while(1)
@@ -110,10 +109,6 @@ static int testdisk_disk_selection_ncurses(int verbose,int dump_ind, const list_
wattroff(stdscr, A_REVERSE);
}
}
- if(i<=NBR_DISK_MAX && element_disk==NULL)
- options="OQ";
- else
- options="PNOQ";
{
int line=INTER_NOTE_Y;
mvwaddstr(stdscr,line++,0,"Note: ");
@@ -128,6 +123,9 @@ static int testdisk_disk_selection_ncurses(int verbose,int dump_ind, const list_
if(has_colors())
wbkgdset(stdscr,' ' | COLOR_PAIR(0));
wmove(stdscr,line++,0);
+#ifdef SUDO_BIN
+ use_sudo=1;
+#endif
}
#endif
#endif
@@ -137,6 +135,20 @@ static int testdisk_disk_selection_ncurses(int verbose,int dump_ind, const list_
wmove(stdscr,line,0);
wprintw(stdscr,"detection, and install the latest OS patches and disk drivers.");
}
+ if(use_sudo > 0)
+ {
+ if(i<=NBR_DISK_MAX && element_disk==NULL)
+ options="OSQ";
+ else
+ options="PNOSQ";
+ }
+ else
+ {
+ if(i<=NBR_DISK_MAX && element_disk==NULL)
+ options="OQ";
+ else
+ options="PNOQ";
+ }
command = wmenuSelect_ext(stdscr, INTER_NOTE_Y-1, INTER_DISK_Y, INTER_DISK_X, menuMain, 8,
options, MENU_HORIZ | MENU_BUTTON | MENU_ACCEPT_OTHERS, &menu,NULL);
switch(command)
@@ -189,6 +201,9 @@ static int testdisk_disk_selection_ncurses(int verbose,int dump_ind, const list_
}
}
break;
+ case 's':
+ case 'S':
+ return 1;
case 'q':
case 'Q':
return 0;