9

Provided a user is authorized to access something, how can he execute a system call directly, like geteuid() - get effective user ID (it's just an example) from bash, how could I do it?

Pierre B
  • 2,213
  • 2
    Invoking a system call directly involves loading one or more registers with values and executing an assembly instruction. You're not going to be able to do that directly from bash. – Andy Dalton Nov 06 '17 at 14:17
  • 1
    The most straight-forward way would be to write a small C program. Are you asking for a way to do this in pure Bash? – igal Nov 06 '17 at 14:31
  • 1
  • Why not use the library call wrapper - geteuid() - to the syscall - sys_geteuid() - in Linux? 2. Why do you want to use a syscall directly?
  • – schaiba Nov 06 '17 at 14:33
  • 1
    I do wonder what the purpose behind this is? It doesn't make much sense to manually make the system calls e.g. for copying a file, since you could use cp or cat directly. (And that's not even very hard to do on the system call level.) Is there some specific operation or system call you have in mind, or is this just about how system calls are made in general, or something else? – ilkkachu Nov 06 '17 at 14:47
  • 4
    Why do you ask? Are you looking just for id command, or are you wanting to add a new system call into your kernel and asking how you would use it? Is the question specific to geteuid or generic to all system calls of syscalls(2)? Please edit your question to improve and motivate it! – Basile Starynkevitch Nov 06 '17 at 14:51
  • @BasileStarynkevitch your link to syscalls is this – Timo Dec 05 '22 at 20:04