3

For listing jobs added by at and batch I use atq, but it lists only my jobs. I can run atq with root privileges and then it lists jobs from all users.

How can I list all jobs without root privileges?

klew
  • 272
  • 7
  • 17

2 Answers2

4

This may not be the answer you want, but strictly speaking, you could boot a Live CD and use that to look at the files in /var/spool/at (or equivalent).

The privacy and security provisions of Unix/Linux does not allow you to do what you want. The at files are stored by default with "other" read privilege set to off.

kmarsh
  • 4,940
  • 1
  • 23
  • 32
  • Ok, so maybe I can start some deamon/program in cron/etc with root privileges that provide this data for non-root users. Is there any tool that do this? Or maybe you have some suggestions how to do it with scripts? – klew Nov 24 '09 at 13:57
  • 1
    int main(int argc, char *argv[]) { setreuid(0, 0); argv[0] = "/usr/bin/atq"; exec(argv[0], argv); return 0; } – u1686_grawity Nov 24 '09 at 18:03
  • Assuming it was compiled by root and chmoded to setuid, this would run atq for a regular user as root, in a similar manner as sudo /usr/bin/atq. But it would still run with root privileges. – kmarsh Nov 24 '09 at 18:32
  • Ok, it works, but I changed exec() to execv() (it didn't compile with exec() ). Thanks! I think that to get this informations without root privileges (at least when running a something-like-atq) I could add a cron job that grabs this data as root and stores it in a file which is readable for everyone. – klew Nov 24 '09 at 19:19
2

you might create a custom little program that runs atq and give it suid root.

beware that:

  • if you do something wrong, it will be very easily exploitable to gain root access
  • you can't suid a script, it has to be an executable
o0'.
  • 2,288
  • 4
  • 30
  • 46