diff options
-rw-r--r-- | src/phmain.c | 29 | ||||
-rw-r--r-- | src/sudo.c | 1 | ||||
-rw-r--r-- | src/testdisk.c | 27 |
3 files changed, 46 insertions, 11 deletions
diff --git a/src/phmain.c b/src/phmain.c index f0450a71..7ed88291 100644 --- a/src/phmain.c +++ b/src/phmain.c @@ -348,11 +348,23 @@ int main( int argc, char **argv ) log_info("\n"); reset_list_file_enable(options.list_file_format); file_options_load(options.list_file_format); - use_sudo=do_curses_photorec(¶ms, &options, list_disk); +#ifdef SUDO_BIN + if(list_disk==NULL) + { +#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(DJGPP) +#else +#ifdef HAVE_GETEUID + if(geteuid()!=0) + use_sudo=2; +#endif +#endif + } +#endif + if(use_sudo==0) + use_sudo=do_curses_photorec(¶ms, &options, list_disk); #ifdef HAVE_NCURSES end_ncurses(); #endif - delete_list_disk(list_disk); log_info("PhotoRec exited normally.\n"); if(log_close()!=0) { @@ -362,14 +374,19 @@ int main( int argc, char **argv ) { printf("PhotoRec syntax error: %s\n", params.cmd_run); } - else - { - printf("PhotoRec exited normally.\n"); - } #ifdef SUDO_BIN if(use_sudo>0) + { + printf("\n"); + if(use_sudo>1) + printf("No disk found.\n"); + printf("PhotoRec will try to restart itself using the sudo command to get\n"); + printf("root (superuser) privileges.\n"); + printf("\n"); run_sudo(argc, argv); + } #endif + delete_list_disk(list_disk); free(params.recup_dir); #ifdef ENABLE_DFXML xml_clear_command_line(); @@ -50,6 +50,7 @@ void run_sudo(int argc, char **argv) argv2[i+1]=NULL; printf("sudo may ask your user password, it doesn't ask for the root password.\n"); printf("Usually there is no echo or '*' displayed when you type your password.\n"); + printf("\n"); fflush(stdout); if(execv(argv2[0], argv2)<0) { diff --git a/src/testdisk.c b/src/testdisk.c index 209fc39f..9d52c855 100644 --- a/src/testdisk.c +++ b/src/testdisk.c @@ -412,7 +412,20 @@ int main( int argc, char **argv ) log_info("\n"); } log_info("\n"); - use_sudo=do_curses_testdisk(verbose,dump_ind,list_disk,saveheader,cmd_device,&cmd_run); +#ifdef SUDO_BIN + if(list_disk==NULL) + { +#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(DJGPP) +#else +#ifdef HAVE_GETEUID + if(geteuid()!=0) + use_sudo=2; +#endif +#endif + } +#endif + if(use_sudo==0) + use_sudo=do_curses_testdisk(verbose,dump_ind,list_disk,saveheader,cmd_device,&cmd_run); #ifdef HAVE_NCURSES end_ncurses(); #endif @@ -455,17 +468,21 @@ int main( int argc, char **argv ) { printf("TestDisk: Log file corrupted!\n"); } - else - { - printf("TestDisk exited normally.\n"); - } if(write_used!=0) { printf("You have to reboot for the change to take effect.\n"); } #ifdef SUDO_BIN if(use_sudo>0) + { + printf("\n"); + if(use_sudo>1) + printf("No disk found.\n"); + printf("TestDisk will try to restart itself using the sudo command to get\n"); + printf("root (superuser) privileges.\n"); + printf("\n"); run_sudo(argc, argv); + } #endif return 0; } |