c++ - setuid bit on, yet program can't open a superuser file -


i have file superuser.cpp created superuser access permissions 770. now, superuser creates file setuiddemonstration.cpp in superuser.cpp opened using open("superuser.cpp", o_rdonly). .cpp , object file of setuiddemonstration.cpp have permissions rwxrwxr-x. now, questions are:-

  1. when ran program setuiddemonstration, in both normal , superuser mode not open superuser.cpp. why? @ least, superuser mode should have succeeded in opening it.

  2. now, sudo chmod 4775 setuiddemonstration. should allow program open superuser.cpp in normal mode because euid of superuser during execution setuid bit has been set when sudo chmod 4775 setuiddemonstration had been run. couldn't. also, when printed euid while running normal mode, printed 1000 , not 0. why?

update: pointing out mistake. have removed '/' file path , work superuser. after sudo chmod 4775 setuiddemonstration, normal mode run program falis open file. pls explain.

because /superuser.cpp name of file in filesystem root, not in current working directory. use superuser.cpp or ./superuser.cpp if file in same path when run program.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -