What is it?
I have set up my own job queuing system which works fine. A user can enter the number of cores (threads) they want to use and the maximum time after which their program will be sigkilled. The queue-system communicates via files. In particular, the following executables and files exist:
Files
root jobq 0 Jun 29 10:53 .commands
root jobq 45591 Jun 29 10:52 log.txt
root jobq 0 Jun 29 10:53 .queue
root jobq 48 Jun 29 10:52 .status
root jobq 30 Jun 28 08:40 .system_buffer
Executables
root jobq 52 Jun 22 08:36 .jobq_exec
root jobq 1100896 Jun 22 08:36 jobq_server
root jobq 271 Jun 22 08:36 jobq_server_start
root jobq 364072 Jun 22 08:36 jobq_server_stop
root jobq 363928 Jun 22 08:36 jobq_status
root jobq 368112 Jun 22 08:36 jobq_stop
root jobq 372512 Jun 22 08:36 jobq_submit
The way it works:
jobq_server_start
is a simple shell script, that checks if a process with name jobq_server is running, and if not, will try to start it.
jobq_server_stop
will write to the .commands
file.
jobq_status
will write to the .commands
file and read from the .status
file.
jobq_submit
will write to the .queue file.
.jobq_exec
is a shell script that will start a job via taskset
, which is passed by command line argument and redirects the outputs
.jobq_stop
will write to the .commands
file
jobq_server
is a binary file, that will read and write to .commands
, log.txt
, .queue
, .status
and .system_buffer
.
Question
Currently everything is used by one user (jobq
), which is shared by different people. I'd like to set up file restrictions, so that
- each user can only run the
jobq_submit
,jobq_status
andjobq_stop
commands as themselves (so they need to login as for examplejohndoe
, not asjobq
). If possible, they should not be allowed to edit the text files directly (.commands
,.queue
). - each job will start as the user who submitted it (and as such, can only stop jobs that they started). This will presumably mean that the
.job_exec
script needs to be altered (see below), to switch to the user. I assume this also means that the server can only be started as root, which is fine.
Script Info
.jobq_exec
#!/bin/bash
cd $1
$5 1> $2 2> $3 &
echo $! > $4 2>&1
usage (this is executed by the server binary)
.job_exec 1:working_directory 2:out_file 3:err_file 4:buffer_file 5:'taskset -ac 1,2,3,4 command cmd_args...'
(added argument numbers for clarity)
Additional info
I'm running Linux Mint 20.3 Una
uname -r
5.4.0-105-generic