Changes: New test to check that invoker passes uid and gid to launcher

RevBy: TrustMe
pull/1/head
Nimika Keshri 15 years ago
parent a5c7d2b19b
commit bd66afb9a2

@ -22,6 +22,7 @@
#include <MApplicationWindow>
#include <MExport>
#include <QTimer>
#include <iostream>
#ifdef HAVE_MCOMPONENTCACHE
#include <mcomponentcache.h>
@ -33,6 +34,11 @@ M_EXPORT int main(int argc, char ** argv)
MApplication *app = MComponentCache::mApplication(argc, argv);
#endif
QTimer::singleShot(5, app, SLOT(quit()));
int usr_id = getuid();
int grp_id = getgid();
std::cerr << "uid=" << usr_id <<"\n";
std::cerr << "gid=" << grp_id <<"\n";
app->exec();
return 29;

@ -645,6 +645,63 @@ class launcher_tests (unittest.TestCase):
self.assert_(app_st_wo_inv == app_st_w_inv, "The invoker returns a wrong exit status")
def test_018_invoker_gid_uid(self):
"""
To Test that the set gid and uid is passed from invoker process to launcher
"""
#get the id in user mode
print ("In User Mode \n")
st, op = commands.getstatusoutput('su user -c ' "id")
usr_id1 = op.split(' ')[0].split('(')[0]
grp_id1 = op.split(' ')[1].split('(')[0]
print("System %s \nSyetem %s" %(usr_id1, grp_id1))
#get id by running the application using invoker in user mode
app = "invoker --type=m /usr/bin/fala_status.launch"
st, op = commands.getstatusoutput('su user -c "%s"' %app );
usr_id = op.split('\n')[1]
grp_id = op.split('\n')[2]
print("Invoker %s \nInvoker %s" %(usr_id, grp_id))
#get id by running the application without invoker in user mode
app = "/usr/bin/fala_status.launch"
st, op = commands.getstatusoutput('su user -c "%s"' %app );
usr_id2 = op.split('\n')[3]
grp_id2 = op.split('\n')[4]
print("Application %s \nApplication %s" %(usr_id2, grp_id2))
self.assert_(usr_id == usr_id1, "The correct UID is not passed by invoker")
self.assert_(grp_id == grp_id1, "The correct GID is not passed by invoker")
self.assert_(usr_id == usr_id2, "The correct UID is not passed by invoker")
self.assert_(grp_id == grp_id2, "The correct GID is not passed by invoker")
#get the id in root mode
print ("In Root Mode \n")
st, op = commands.getstatusoutput("id")
usr_id1 = op.split(' ')[0].split('(')[0]
grp_id1 = op.split(' ')[1].split('(')[0]
print("System %s \nSyetem %s" %(usr_id1, grp_id1))
#get id by running the application using invoker in root mode
app = "invoker --type=m /usr/bin/fala_status.launch"
st, op = commands.getstatusoutput("%s" %app );
usr_id = op.split('\n')[1]
grp_id = op.split('\n')[2]
print("Invoker %s \nInvoker %s" %(usr_id, grp_id))
#get id by running the application without invoker in root mode
app = "/usr/bin/fala_status.launch"
st, op = commands.getstatusoutput("%s" %app );
usr_id2 = op.split('\n')[3]
grp_id2 = op.split('\n')[4]
print("Application %s \nApplication %s" %(usr_id2, grp_id2))
self.assert_(usr_id == usr_id1, "The correct UID is not passed by invoker")
self.assert_(grp_id == grp_id1, "The correct GID is not passed by invoker")
self.assert_(usr_id == usr_id2, "The correct UID is not passed by invoker")
self.assert_(grp_id == grp_id2, "The correct GID is not passed by invoker")
# main

@ -69,6 +69,10 @@
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_017_invoker_exit_status</step>
</case>
<case name="gid-uid" type="Functional" description="To Test that the set gid and uid is passed from invoker process to launcher" timeout="120" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_018_invoker_gid_uid</step>
</case>
<environments>
<scratchbox>true</scratchbox>

Loading…
Cancel
Save