Co.Sinecure
April 14th, 2008, 03:00 AM
This how-to describes the creation of a severely restricted user, that is locked into viewing a particular log file.
This is a bit of a pet project, tied to the log file of a jabber bot that I've created.
The Jabber bot tracks the arrival times of our local coffee van which comes every morning, and attempts to estimate the time it should arrive based on historical data.
I'm going on leave from work for a few of weeks, so I decided to allow some co-workers watch over my coffee-bot, and allow them to see its status via the logs. I did not particularly want to leave my machine completely open to them, while trustworthy, they would never miss a pranking opportunity!
Basically the idea is the user is given a shell that is actually a bash script that runs a watch and tail command.
Written using Feisty 7.04
Step 1:
Write the script that will be executed
sudo vim /usr/bin/coffee-watch
#! /bin/bash
watch tail -n 80 /home/cosinecure/etc/jabber-bot/logfile.log
What this script does is call the watch command, which is a program that executes its parameters periodically. It defaults to 2 seconds, and so every 2 seconds it will run tail -n 80 /.../logfile.log. This echos the last 80 lines of the logfile to the terminal.
sudo chmod +x /usr/bin/coffee-watchStep 2:
Set the script as a shell-able command
sudo vim /etc/shells Add the line
/usr/bin/coffee-watch
Step 3:
Create the user.
Either use the menu System > Administration > Users and Groups
Or the command line *I didn't do this way so not sure if this is all you need..
sudo adduser --shell /usr/bin/coffee-watchImportant thing to remember is that your user has their shell set to /usr/bin/coffee-watchStep 4:
Make sure your log file and the path to the log file has the right permissions! I actually added the user to my username's group so that it could access that file.
Step 5: Test it!
Switch to tty 1 and attempt to log in
Ctrl+Alt+F1Step 6:
Leave me feedback if you used this and any problems/ideas you had!
I apologise for the lack of screenshots. Didn't have long to write this up!
This is a bit of a pet project, tied to the log file of a jabber bot that I've created.
The Jabber bot tracks the arrival times of our local coffee van which comes every morning, and attempts to estimate the time it should arrive based on historical data.
I'm going on leave from work for a few of weeks, so I decided to allow some co-workers watch over my coffee-bot, and allow them to see its status via the logs. I did not particularly want to leave my machine completely open to them, while trustworthy, they would never miss a pranking opportunity!
Basically the idea is the user is given a shell that is actually a bash script that runs a watch and tail command.
Written using Feisty 7.04
Step 1:
Write the script that will be executed
sudo vim /usr/bin/coffee-watch
#! /bin/bash
watch tail -n 80 /home/cosinecure/etc/jabber-bot/logfile.log
What this script does is call the watch command, which is a program that executes its parameters periodically. It defaults to 2 seconds, and so every 2 seconds it will run tail -n 80 /.../logfile.log. This echos the last 80 lines of the logfile to the terminal.
sudo chmod +x /usr/bin/coffee-watchStep 2:
Set the script as a shell-able command
sudo vim /etc/shells Add the line
/usr/bin/coffee-watch
Step 3:
Create the user.
Either use the menu System > Administration > Users and Groups
Or the command line *I didn't do this way so not sure if this is all you need..
sudo adduser --shell /usr/bin/coffee-watchImportant thing to remember is that your user has their shell set to /usr/bin/coffee-watchStep 4:
Make sure your log file and the path to the log file has the right permissions! I actually added the user to my username's group so that it could access that file.
Step 5: Test it!
Switch to tty 1 and attempt to log in
Ctrl+Alt+F1Step 6:
Leave me feedback if you used this and any problems/ideas you had!
I apologise for the lack of screenshots. Didn't have long to write this up!