What the best way to create a log file in an rpm spec file? The service I'm creating runs under an unprivileged user so cannot create files in /var/log/.
Asked
Active
Viewed 4,320 times
1 Answers
3
You could create /var/log/myservice/
directory and make it owned by your user.
Inside %install or make install: (ignoring buildroot & such)
install -d /var/log/myservice -o serviceuser -m 750
This assumes you are running your service similarly to apache which often runs as user apache
and still puts logs in var/log/apache
Then add the corresponding rule for /var/log/myservice
in your spec file.
%dir /var/log/myservice

6EQUJ5
- 3,142
- 1
- 21
- 29
-
-
How about adding the directory normally, and useradd'ing and chown'ing it in %post ? – 6EQUJ5 Mar 10 '14 at 05:27
-
+1 but you actually want to useradd in %pre and specify the owner user/group in the %files section – guido Mar 13 '14 at 11:49