-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix line and add group/user libraries
- Loading branch information
1 parent
a9cde6e
commit 80e91b3
Showing
7 changed files
with
91 additions
and
28 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Manage a local group. Must specify id and name. Can optionally specify members, paths to group and gshadow, and enable removal. | ||
|
||
local line = import './line.libsonnet'; | ||
|
||
function(id, members='', name, pathGroup='/etc/group', pathGshadow='/etc/gshadow', remove=false) | ||
local vars = { | ||
id: id, | ||
members: members, | ||
name: name, | ||
}; | ||
|
||
local replaceRemove = if remove then '""'; | ||
|
||
[ | ||
line(match='"(?m)^%s:.*"' % name, path=pathGroup, replaceChange='"%(name)s:x:%(id)s:%(members)s"' % vars, replaceRemove=replaceRemove), | ||
line(match='"(?m)^%s:.*"' % name, path=pathGshadow, replaceChange='"%(name)s:|::%(members)s"' % vars, replaceRemove=replaceRemove), | ||
] |
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Manage a local user. Must specify id and name. Can optionally specify members, paths to group and gshadow, and disable removal. | ||
|
||
local line = import './line.libsonnet'; | ||
|
||
function(comment, gid, hash='*', home='/bin', id, name, pathPasswd='/etc/passwd', pathShadow='/etc/shadow', remove=false, shell='/usr/sbin/nologin') | ||
local vars = { | ||
comment: comment, | ||
gid: gid, | ||
hash: hash, | ||
home: home, | ||
id: id, | ||
name: name, | ||
shell: shell, | ||
}; | ||
|
||
local replaceRemove = if remove then '""' else null; | ||
|
||
[ | ||
{ | ||
id: '%s password age' % name, | ||
check: '(grep %s: /etc/shadow || echo "::$(($(date +%%s)/60/60/24))") | cut -d: -f3' % name, | ||
envPrefix: 'age', | ||
}, | ||
line(match='"(?m)^%s:.*"' % name, path=pathPasswd, replaceChange='"%(name)s:x:%(id)s:%(gid)s:%(comment)s:%(home)s:%(shell)s"' % vars, replaceRemove=replaceRemove), | ||
line(match='"(?m)^%s:.*"' % name, path=pathShadow, replaceChange='"%(name)s:%(hash)s:${age_CHECK_OUT}:0:99999:7:::"' % vars, replaceRemove=replaceRemove), | ||
] |
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
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