Created
December 12, 2013 20:35
-
-
Save Kilobyte22/7934965 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user: | |
someone: NOPE | |
group: | |
somegroup: YOU GUYS ALL SUCK | |
#default: uncomment this to set a default message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
=begin | |
Slightly advanced nologin shell | |
=end | |
require 'etc' | |
require 'yaml' | |
cfg = YAML.load_file('/etc/nope-login.yml') | |
$user = ENV['USER'] | |
msg = cfg['user'][$user] | |
def die msg | |
puts msg | |
exit 1 | |
end | |
die msg if msg | |
Etc.group do |gr| | |
if gr.mem.include? $user | |
msg = cfg['group'][gr.name] | |
die msg if msg | |
end | |
end | |
die cfg['default'] || 'No login for you' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment