summaryrefslogtreecommitdiffstats
path: root/meta-security/lib/oeqa/runtime/files/notroot.py
blob: f0eb0b5b95eb0349324144132a55ebc4d37ca1db (plain)
@media only all and (prefers-color-scheme: dark) { .highlight .hll { background-color: #49483e } .highlight .c { color: #75715e } /* Comment */ .highlight .err { color: #960050; background-color: #1e0010 } /* Error */ .highlight .k { color: #66d9ef } /* Keyword */ .highlight .l { color: #ae81ff } /* Literal */ .highlight .n { color: #f8f8f2 } /* Name */ .highlight .o { color: #f92672 } /* Operator */ .highlight .p { color: #f8f8f2 } /* Punctuation */ .highlight .ch { color: #75715e } /* Comment.Hashbang */ .highlight .cm { color: #75715e } /* Comment.Multiline */ .highlight .cp { color: #75715e } /* Comment.Preproc */ .highlight .cpf { color: #75715e } /* Comment.PreprocFile */ .highlight .c1 { color: #75715e } /* Comment.Single */ .highlight .cs { color: #75715e } /* Comment.Special */ .highlight .gd { color: #f92672 } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gi { color: #a6e22e } /* Generic.Inserted */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color:
#!/usr/bin/env python
#
# Script used for running executables with custom labels, as well as custom uid/gid
# Process label is changed by writing to /proc/self/attr/curent
#
# Script expects user id and group id to exist, and be the same.
#
# From adduser manual: 
# """By  default,  each  user  in Debian GNU/Linux is given a corresponding group 
# with the same name. """
#
# Usage: root@desk:~# python notroot.py <uid> <label> <full_path_to_executable> [arguments ..]
# eg: python notroot.py 1000 User::Label /bin/ping -c 3 192.168.1.1
#
# Author: Alexandru Cornea <alexandru.cornea@intel.com>
import os
import sys

try:
	uid = int(sys.argv[1])
	sys.argv.pop(1)
	label = sys.argv[1]
	sys.argv.pop(1)
	open("/proc/self/attr/current", "w").write(label)
	path=sys.argv[1]
	sys.argv.pop(0)
	os.setgid(uid)
	os.setuid(uid)	
	os.execv(path,sys.argv)

except Exception,e:
	print e.message
	sys.exit(1)