LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-03-2013, 05:58 AM   #1
sietze1977
LQ Newbie
 
Registered: Aug 2010
Posts: 21

Rep: Reputation: 0
setting time restrictions for me and my girlfriend


Since using the computer has become an addiction for me and my partner we need time restrictions.

I feel like a dumb newbie because I have not succeeded in making it work, so I post it here. I have been using Linux quite a bit longer than a newbie. I am not very advanced in using it but still know my way around and can use cli if it's not too complicated.

I have added the to the bottom of /etc/gdm3

account required pam_time.so

to make gdm(3) login manager use time restrictions
that I can define in the next file

/etc/security/time.conf

I added the following to it.

*;*;*;A10000-0800

that should disable all services,
all tty's (and gdm to because of what I did to /etc/gdm3)
all users
all days of the week A1
from 0000 till 0800 hours

(one can exceed the time limit but one cannot
login after this time (see below).
When testing it that same evening
I could not login as a normal user anymore through gdm
so I thought that part at least did work.
(root login on the terminal still worked,
and that should also be disabled,
but not until after the issues are fixed)
But the next morning after 0800 I could not login through gdm,
while that should now be possible.
How do I fix this ?

I also made a cronjob to shut down the system
because when you exceed this time limit there is only
something mentioned in the syslog that you exceeded your limit
but it does not automatically logout the user.
Only when reentering the system I get the message permission denied.

crontab -e -u root

added this to the bottom of the crontab

55 23 * * * shutdown -h 5 now

But on both our systems the cronjob does not run
So it does not automatically shutdown.
There fore the time limiting also does not work.
We run Debian Linux.

I also tried to make a warning message appear
on X (windows) but I will open another thread for that
and post a link to that in this one for completeness

I apologize for any language mistakes because
English is not my native speech.

Sietze van de Burgt
 
Old 04-03-2013, 02:12 PM   #2
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
I'm not sure why you wouldn't be allowed to log back in at 0800. (Caveat: I haven't used this feature on Linux but I know it works on other UNIX-variants.) Check the settings to be sure you have the time correctly defined. Specifically, check out the possible need for a "!" character in the time specification. You're right, though... that won't kick you out when the restricted window begins; only new logins would be prohibited.

Rebooting to kick everyone out seems a little draconian.

Perhaps you could set up a little utility that runs in the background when you log in that periodically checks to see how long you've been logged on and, if it's longer than your desired duration or outside of the window you want to allow, starts popping up an "xmessage" window every few minutes that says something like: "Hey! You've been logged in long enough! Get a life!" with options to click on "OK, I'll get off now." or "Go away, I'm having too much fun." options and log which one you clicked on. (Then you and your SO can compare log files so you can see how the other is handling their Internet addiction.)

Last edited by rnturn; 04-03-2013 at 03:29 PM. Reason: Forgot comment about the "!" character in the PAM time filter.
 
Old 04-03-2013, 02:23 PM   #3
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Hi how about using the shutdown command to shutdown at set time
Have a look here
http://linux.101hacks.com/unix/shutdown/#examples

It might not be what you want but might be a thought

It could be run as a cron job to shutdown everyday at set time

Last edited by spiky0011; 04-03-2013 at 03:17 PM.
 
Old 04-03-2013, 08:06 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
1. not being able to login again may be down to pam_tally locking you out after n (usually 3) attempts.

2. the cron job issue could be due to the fact that the PATH inside cron is minimal; try giving the full path /sbin/shutdown

In both cases, check the log files eg /var/log/cron, messages, secure etc
 
Old 04-04-2013, 01:12 PM   #5
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
I don't think that technical solution for this problem exist - even if you'll manage what you are trying to do,you always can easily boot from live cd or change time in the BIOS setup.
 
Old 04-05-2013, 10:45 AM   #6
sietze1977
LQ Newbie
 
Registered: Aug 2010
Posts: 21

Original Poster
Rep: Reputation: 0
I initially tried using

shutdown -h 00:00

This worked but caused the system
to prompt a message shutdown is already running
when I tried to shutdown the system any time before midnight,
so this was not practical.

The cronjob is running now.
I originally tried to ad it with.

crontab -e -u root

That did not work.
But then I tried to add it directly in

/etc/crontab

That solved the problem for now.

I discovered I have to add

account required pam_time.so

to the file

/etc/pam.d/login

To disable root login also.

At least on debian linux this has to be added
to files in /etc/pam.d
to disable a particular service use the corresponding file.

However the unable to login again problem
in the morning still persists
 
Old 04-06-2013, 07:09 AM   #7
sietze1977
LQ Newbie
 
Registered: Aug 2010
Posts: 21

Original Poster
Rep: Reputation: 0
Okay I solved it partially

The day specification should be

Al that is capitol A small l

so that makes the statement

*;*;*;Al0000-0800

But now it says in /var/log/aut.log

gdm-session-worker[2061]: pam_ck_connector(gdm3:session): nox11 mode, ignoring PAM_TTY :0
 
Old 04-06-2013, 07:16 AM   #8
sietze1977
LQ Newbie
 
Registered: Aug 2010
Posts: 21

Original Poster
Rep: Reputation: 0
Okay I solved it partially

The day specification should be

Al that is capitol A small l

so that makes the statement

*;*;*;Al0000-0800

But this does not solve the login again problem
the following morning

Now it says in /var/log/aut.log

gdm-session-worker[2061]: pam_ck_connector(gdm3:session): nox11 mode, ignoring PAM_TTY :0
 
Old 04-07-2013, 05:22 PM   #9
sietze1977
LQ Newbie
 
Registered: Aug 2010
Posts: 21

Original Poster
Rep: Reputation: 0
The login problem
in the morning after 0800
is probably a bug somewhere.
I don't know if it is a Debian problem
or something in Linux in general.
I hope it is resolved soon.
If so I will post here again.
 
Old 04-07-2013, 05:29 PM   #10
sietze1977
LQ Newbie
 
Registered: Aug 2010
Posts: 21

Original Poster
Rep: Reputation: 0
in /etc/pam.d/common-session
I removed nox11 behind this statement

session optional pam_ck_connector.so nox11

so now it becomes.

session optional pam_ck_connector.so


This should solve some problems but it still does not function correct.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PAM time restrictions - changing Time.conf so it gets time from sql table noodlesoffire Linux - Newbie 1 04-04-2010 04:41 PM
Time restrictions on Linux. cayuga Linux - Software 1 11-11-2007 05:28 PM
Time Restrictions on IPCop depam Linux - Software 2 08-16-2006 09:28 PM
Time Restrictions - porttime - logoutd gdw Slackware 1 02-25-2003 01:23 AM
setting user restrictions artman62 Linux - Networking 1 08-31-2002 04:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration