Reputation: 1201
I want to exec a script when a new root process starts (on Linux). How can I simply do that ?
Upvotes: 1
Views: 271
Reputation: 4209
This answer explains how to get notified about creation of new processes and will tell you process IDs.
Given the process ID you can trivially determine whether the process belongs to UID 0, i.e. user root
.
Upvotes: 0
Reputation: 5734
I guess this will be tricky, as the script would probably also be spawned as root -- and then even every external command in it.
But I think it is possible with SystemTap.
Upvotes: 1