Commit aa01fa97 authored by Rusty Myers's avatar Rusty Myers

Merge pull request #1 from CLCMacTeam/LogoutNotRestart

Logout not restart Branch Pull
parents 8885baf2 a9f80e8b
.psuIdleLogout.rbuistate
Builds - psuIdleLogout.rbvcp/*
#tag BuildAutomation Begin BuildStepList Linux Begin BuildProjectStep Build End End Begin BuildStepList Mac OS X Begin BuildProjectStep Build End End Begin BuildStepList Windows Begin BuildProjectStep Build End End #tag EndBuildAutomation
\ No newline at end of file
#tag BuildAutomation Begin BuildStepList Linux Begin BuildProjectStep Build End End Begin BuildStepList Mac OS X Begin IDEScriptBuildStep SaveProject , AppliesTo = 0 DoCommand "SaveFile" End Begin BuildProjectStep Build End Begin IDEScriptBuildStep UnDock , AppliesTo = 0 Dim AppLocation as String = CurrentBuildAppName + ".app" AppLocation = AppLocation.ReplaceAll( " ", "\ " ) AppLocation = CurrentBuildLocation + "/" + AppLocation //@ More cocoa info.plist keys here: // https://developer.apple.com/library/ios/documentation/general/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html Call DoShellCommand("/usr/bin/defaults write " + AppLocation + "/Contents/Info ""LSBackgroundOnly"" -bool ""true""") End Begin IDEScriptBuildStep tarProject , AppliesTo = 0 // Set Variables dim packageLoc, res, tarname as string tarname = "Idle-Logout.tar.bz2" packageLoc = "/Users/rzm102/Documents/_Programing/CLC\ Git/Software\ Packages/idle-logout/" if CurrentBuildLocation="/Users/rzm102/Documents/_Programing/Git/IdleLogout/Builds\ \-\ psuIdleLogout.rbvcp/Mac\ OS\ X\ \(Intel\)" OR CurrentBuildLocation="/Users/rzm102/Documents/_Programing/Git/IdleLogout/Builds\ \-\ psuIdleLogout.rbvcp/Mac\ OS\ X\ \(Cocoa\ Intel\)" then //print "Build Location: "+CurrentBuildLocation // Tar up folder res = DoShellCommand _ ("cd "+CurrentBuildLocation+"; /usr/bin/tar -c --exclude='.svn' -vjf "+tarname+" *") if res = "" then print "Results: "+res end // Delete old tar // print "rm "+packageLoc+tarname res = DoShellCommand _ ("rm "+packageLoc+tarname) // Move tar to luggage folder // print "mv "+CurrentBuildLocation+"/"+tarname+" "+packageLoc res = DoShellCommand _ ("mv "+CurrentBuildLocation+"/"+tarname+" "+packageLoc) // Make package res = DoShellCommand _ ("cd "+packageLoc+"; make pkg; open "+packageLoc) print res else print "Not on rusty's mac. Skipping pkg creation" //print CurrentBuildLocation//print "Build Location: "+CurrentBuildLocation end End End Begin BuildStepList Windows Begin BuildProjectStep Build End End #tag EndBuildAutomation
\ No newline at end of file
......
if getPID("idle") = 0 then
display dialog "Idle time is not currently being monitored." buttons {"OK"} default button "OK"
return
end if
set CR to return
set CRCR to return & return
set warnMsg to " •WARNING•"
set warnMsg to warnMsg & CRCR & "You are about to disable the automatic idle logout feature, which logs you out if you are idle too long. "
set warnMsg to warnMsg & CRCR & "Disabling this feature will expose you to the following problems "
set warnMsg to warnMsg & "should you leave the Mac unattended and remain logged in:"
set warnMsg to warnMsg & CRCR & "1) Others can use this Mac to access your files."
set warnMsg to warnMsg & CRCR & "2) Others can use this Mac to charge printing to your Penn State Access Account."
set warnMsg to warnMsg & CRCR & "3) Others can use this Mac to pose as you."
set warnMsg to warnMsg & CRCR & "Do you agree to stay in the vicinity of this computer to prevent such abuses?"
set userSelection to the button returned of (display dialog warnMsg with icon 2 buttons {"Cancel Request", "I Agree. Disable Auto Logout."} default button 1)
if userSelection contains "cancel" then
display dialog "Request cancelled by user" buttons {"OK"} default button 1
return
end if
killApp("idle")
if getPID("idle") = 0 then
display dialog "Automatic Idle Logout has been disabled." buttons {"OK"} default button "OK"
else
display dialog "There was a problem with disabling Automatic Idle Logout." buttons {"OK"} default button "OK"
end if
--••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
--• subroutines follow •
--••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
----------------------------------------------------------------------
-- getAppCount - return count of apps
----------------------------------------------------------------------
on getAppCount(appName)
set appCounter to (do shell script ("pid=`/bin/ps auxww | /usr/bin/grep -v grep | /usr/bin/grep -i -c " & quoted form of appName & "` ; [[ -n $pid ]] && echo $pid || echo 0 ")) as integer
return appCounter
end getAppCount
----------------------------------------------------------------------
-- getPID - return an app's processor id number
----------------------------------------------------------------------
on getPID(appName)
set appPID to (do shell script ("pid=`/bin/ps auxww | /usr/bin/grep -v grep | /usr/bin/grep -v psuGetPID | /usr/bin/grep -i " & quoted form of appName & " $appName | /usr/bin/awk '{print $2}'` ; [[ -n $pid ]] && echo $pid || echo 0 ")) as integer
return appPID
end getPID
----------------------------------------------------------------------
-- killApp - kill all running copies of an app
----------------------------------------------------------------------
on killApp(appName)
set appKilled to false
repeat while getAppCount(appName) > 0
set appPID to getPID(appName)
if appPID 0 then
try
do shell script ("/bin/kill -9 " & appPID)
end try
set appKilled to true
delay 1
end if
end repeat
end killApp
#!/bin/bash
# Written by Rusty Myers
# 2012-11-06
# postflight to tell etc/sudoers to add code
DEST_VOLUME="${3}"
TIME=`date "+%Y-%m-%d-%H-%M-%S"`
# Allow Runtime to run with root privileges without prompting for an admin password
# check sudoers for psuRebootNow.pl
RUN_AS_ROOT=`grep "psuRebootNow.pl" "${DEST_VOLUME}"/etc/sudoers`
if [ -n "${RUN_AS_ROOT}" ] # If it's there
then
# Remove it from /etc/sudoers if it exists
sed /psuRebootNow.pl/d "${DEST_VOLUME}"/etc/sudoers > "${DEST_VOLUME}"/tmp/sudoers
# Make a copy of the current version
mv "${DEST_VOLUME}"/etc/sudoers "${DEST_VOLUME}"/etc/sudoers."${TIME}"
# Replace old version with new version
mv "${DEST_VOLUME}"/tmp/sudoers "${DEST_VOLUME}"/etc/sudoers
else
# Make a copy of the current version
cp "${DEST_VOLUME}"/etc/sudoers "${DEST_VOLUME}"/etc/sudoers."${TIME}"
fi
# Add it back into /etc/sudoers
echo 'ALL ALL=NOPASSWD:/Library/CLMshared/psuRebootNow.pl' >> "${DEST_VOLUME}"/etc/sudoers
# Check permissions and reload sudoers file
chmod 440 "${DEST_VOLUME}"/etc/sudoers
chown root:wheel "${DEST_VOLUME}"/etc/sudoers
visudo -c
exit 0
#!/usr/bin/perl -w
#
#--------------------------------------------------------------------------------------------------
#-- psuRebootRequested.pl
#--------------------------------------------------------------------------------------------------
# Program : psuRebootRequested.pl
#
# Purpose : Reboot computer
#
# Loaded By : launchd
# Called By : psuKioskIdleLogout.app touching file /tmp/psu_reboot_requested
#
# Author : <hkr@psu.edu> Ken Rosenberry
#
# Revisions : 2009/08/18 <hkr> Initial version
# : 2010/06/21 <hkr> no longer using /tmp/psu_reboot_now flag file
#--------------------------------------------------------------------------------------------------
# Get name of program for log records.
use File::Basename;
my ( $programName ) = basename($0);
LogData ("-->");
# psuCurrentUser.dat file contains the last logged in user.
# Remove this file, otherwise RunMaint tasks won't run because it looks like a user is logged in.
$current_user_dat_file = '/Library/PSUtemp/psuCurrentUser.dat';
if (-f $current_user_dat_file)
{
LogData("Remove current user file: $current_user_dat_file");
system "/bin/rm $current_user_dat_file";
}
LogData("Rebooting Now!");
LogData ("<--");
system '/sbin/reboot';
exit 0;
#--------------------------------------------------------------------------------------------------
#-- LogData - Print message to log file.
#--------------------------------------------------------------------------------------------------
sub LogData
{
my $text = $_[0] ;
if ( substr($text, -1, 1) ne "\n") { $text = $text . "\n"; } ### Log messages must end w/ newline.
if ( substr($text, 0, 3) eq "-->")
{
$text = substr($text, 0, 3) . $programName . ": launched..." . substr($text, 3);
}
elsif ( substr($text, 0, 3) eq "<--" )
{
$text = substr($text, 0, 3) . $programName . ": ...terminated." . substr($text, 3);
}
else
{
$text = " " . $programName . ": " . $text; ### All other log records indented.
}
$text = (scalar localtime) . " " . $text; ### Timestamp log records.
print $text;
}
This diff is collapsed.
This diff is collapsed.
......@@ -3,30 +3,35 @@ IdleLogout.app
Description
------------
Application to log out users after a specified period of time. The user will see a prompt with a countdown asking them if they wish to log out or continue working ("More Time").
Application to log out users after a specified period of time. The user will see a prompt with a countdown asking them if they wish to log out or continue working ("More Time"). Users can disable the Idle Logout process using the "Disable Idle Logout.applescript".
Download app: [Idle Logout.app](https://github.com/CLCMacTeam/IdleLogout/blob/master/IdleLogout%20app/Idle%20Logout.app1.0b1.zip?raw=true)
Download app: [Idle Logout.app](https://github.com/CLCMacTeam/IdleLogout/blob/LogoutNotRestart/IdleLogout%20app/Idle%20Logout.app1.1b2.zip)
Background
------------
Idle Logout.app was written in RealStudio 2012 R2. It uses the ioreg command to determine how long USB devices have been idle. Once the idle limit is meet, the computer is forcibly restarted to log out any users.
Idle Logout.app was written in RealStudio 2014 R2.1. It uses the ioreg command to determine how long USB devices have been idle. Once the idle limit is meet, the computer is forcibly restarted to log out any users.
The terminal command we use to check idle seconds on USB devices is:
> /bin/echo $((`/usr/sbin/ioreg -c IOHIDSystem | /usr/bin/sed -e '/HIDIdleTime/ !{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000))"
Important Notes
-------------
Idle Logout.app can be run at login with a LaunchAgent under the users context. **In order for the application to work, the /etc/sudoers file needs to be edited to allow all users to run the "psuRebootNow.pl" script (included in the repo under 'IdleLogout app' folder).** View the "IdleLogoutSudoers.sh" script (included in the repo under 'IdleLogout app' folder) to see what changes are made to the /etc/sudoers file. The script can be used as a postflight script in a package while deploying the app.
Idle Logout.app should be run at login with a LaunchAgent under the users context. **UPDATE: The Idle Logout.app is self contained and will force a user logout without the need for external scripts!** The Idle Logout.app will write log files into the /Users/Shared/IdleLogout folder.
You can deploy the "Disable Idle Logout.applescript", as a compiled app, to give users an easy way to stop the Idle Logout process. This is helpful in locations where users need to allow processes to run for longer than you're normal logout time.
**The Idle Logout App will force close any applications the user has open. This will not save any data!**
Preferences
-------------
The Idle Logout.app looks for a preference file in /Library/CLMadmin/Config named "edu.psu.its.clc.IdleLogoutSettings.plist" (included in the repo under 'IdleLogout app' folder). It looks for the following key/string pairs in the plist. If they are missing, it will use the defaults:
The Idle Logout.app looks for the preference file "/Library/CLMadmin/Config/edu.psu.its.clc.IdleLogoutSettings.plist" (included in the repo under 'IdleLogout app' folder). It looks for the following key/string pairs in the plist. If they are missing, it will use the defaults:
* IgnoreUser = Ignore the username, don't force logout.
* IgnoreGroup = Ignore anyone in this group, don't force logout.
* ComputerIdleAfterNumSeconds = Number of seconds before considering the computer abandoned.
* IdleLoopDelaySeconds = Number of seconds to wait between checking the usb idle seconds.
* WaitForUserPromptSeconds = Number of seconds to wait for user to respond to logout prompt.
* WindowTitle = Changes the name name shown in the logout window. Uses String.
Default Values if plist is not installed:
......@@ -35,6 +40,19 @@ Default Values if plist is not installed:
* ComputerIdleAfterNumSeconds = "600"
* IdleLoopDelaySeconds = "30"
* WaitForUserPromptSeconds = "90"
* WindowTitle = "PSU Idle Logout"
ToDo
-------------
* Use CFPrefernces for pref file
* Update code to Cocoa
** Only update UI from main thread
Completed
------------
* 01/2015 - The path to the logout script should be set in the preference file OR the script should be part of the app.
** 01/2015 - Make it part of the .app, create a new method to log out
* 01/2015 - Add preference key for window wording.
Attribution
------------
......
#tag IDEScriptBuildStep Begin IDEScriptBuildStep Script1 , AppliesTo = 0 'Build script for psuIdleLogout.app End #tag IDEScriptBuildStep
\ No newline at end of file
Type=Desktop RBProjectVersion=2013.01 MinIDEVersion=20070100 Class=IdleLogout;IdleLogout.rbbas;&h3007783E;&h0;false Window=LogoutWarning;LogoutWarning.rbfrm;&h3A6788BA;&h0;false MenuBar=MenuBar1;MenuBar1.rbmnu;&h6341CAF0;&h0;false BuildSteps=Build Automation;Build Automation.rbbas;&h2A7E2380;&h0;false Module=LogToFile;LogToFile.rbbas;&h236DD59E;&h0;false Module=Globals;Globals.rbbas;&h7FE3CBE3;&h0;false Module=MiscMethods;MiscMethods.rbbas;&h445F2753;&h0;false Module=myXMLTools;myXMLTools.rbbas;&h6DD0A4A2;&h0;false Module=PlistHelper;PlistHelper.rbbas;&h4AA6652A;&h0;false IDEScriptBuildStep=Script1;Script1.xojo_code;&h6C77DF83;&h0;false AppMenuBar=MenuBar1 MajorVersion=1 MinorVersion=0 SubVersion=1 NonRelease=0 Release=2 InfoVersion= LongVersion=1.0b1, Penn State University/ITS/CLC ShortVersion=1.0b1 WinCompanyName= WinInternalName= WinProductName= AutoIncrementVersionInformation=False BuildFlags=&h4000 BuildLanguage=&h0 DebugLanguage=&h0 Region= WindowsName=My Application.exe MacCarbonMachName=Idle Logout LinuxX86Name=MyApplication MacCreator= MDI=0 MDICaption= DefaultEncoding=&h0 AppIcon=psuIdleLogout.rbres;&h0 OSXBundleID=IdleLogout DebuggerCommandLine= UseGDIPlus=True UseBuildsFolder=True IsWebProject=False
\ No newline at end of file
Type=Desktop RBProjectVersion=2014.021 MinIDEVersion=20070100 Class=IdleLogout;IdleLogout.rbbas;&h3007783E;&h0;false Window=LogoutWarning;LogoutWarning.rbfrm;&h3A6788BA;&h0;false MenuBar=MenuBar1;MenuBar1.rbmnu;&h6341CAF0;&h0;false BuildSteps=Build Automation;Build Automation.rbbas;&h2A7E2380;&h0;false Module=LogToFile;LogToFile.rbbas;&h236DD59E;&h0;false Module=Globals;Globals.rbbas;&h7FE3CBE3;&h0;false Module=MiscMethods;MiscMethods.rbbas;&h445F2753;&h0;false Module=myXMLTools;myXMLTools.rbbas;&h6DD0A4A2;&h0;false Module=PlistHelper;PlistHelper.rbbas;&h4AA6652A;&h0;false MajorVersion=1 MinorVersion=2 SubVersion=0 NonRelease=0 Release=2 InfoVersion= LongVersion=1.2, Penn State University/ITS/CLC ShortVersion=1.2 WinCompanyName= WinInternalName= WinProductName= WinFileDescription= AutoIncrementVersionInformation=False BuildFlags=&h1000 BuildLanguage=&h0 DebugLanguage=&h0 Region= WindowsName=My Application.exe MacCarbonMachName=Idle Logout LinuxX86Name=MyApplication MacCreator= MDI=0 MDICaption= DefaultEncoding=&h0 AppIcon=psuIdleLogout.rbres;&h0 OSXBundleID=edu.psu.idlelogout DebuggerCommandLine= UseGDIPlus=True UseBuildsFolder=True IsWebProject=False
\ No newline at end of file
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment