mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-11 05:39:45 +08:00
Compare commits
10 Commits
dd54a0d927
...
5e0ff8ae4a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e0ff8ae4a | ||
|
|
41c5b9677a | ||
|
|
116be8badd | ||
|
|
01808b3aae | ||
|
|
8b5f01a22c | ||
|
|
f26b428f8e | ||
|
|
70edfaf348 | ||
|
|
8ceff21474 | ||
|
|
510d7a778a | ||
|
|
ecc5aab0e7 |
2
.github/workflows/dependencies.yml
vendored
2
.github/workflows/dependencies.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
|||||||
contents: write # this is needed to push commits and branches
|
contents: write # this is needed to push commits and branches
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
|
|||||||
4
.github/workflows/installer.yml
vendored
4
.github/workflows/installer.yml
vendored
@ -26,7 +26,7 @@ jobs:
|
|||||||
- macos-latest
|
- macos-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ jobs:
|
|||||||
- test
|
- test
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
|
|||||||
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -24,7 +24,7 @@ jobs:
|
|||||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
|
|||||||
2
.github/workflows/project.yml
vendored
2
.github/workflows/project.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
|||||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
- name: Authenticate as @ohmyzsh
|
- name: Authenticate as @ohmyzsh
|
||||||
|
|||||||
4
.github/workflows/scorecard.yml
vendored
4
.github/workflows/scorecard.yml
vendored
@ -36,7 +36,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
@ -60,6 +60,6 @@ jobs:
|
|||||||
retention-days: 5
|
retention-days: 5
|
||||||
|
|
||||||
- name: "Upload to code-scanning"
|
- name: "Upload to code-scanning"
|
||||||
uses: github/codeql-action/upload-sarif@b20883b0cd1f46c72ae0ba6d1090936928f9fa30 # v4.32.0
|
uses: github/codeql-action/upload-sarif@45cbd0c69e560cd9e7cd7f8c32362050c9b7ded2 # v4.32.2
|
||||||
with:
|
with:
|
||||||
sarif_file: results.sarif
|
sarif_file: results.sarif
|
||||||
|
|||||||
26
plugins/adduser/README.md
Normal file
26
plugins/adduser/README.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# adduser
|
||||||
|
|
||||||
|
This plugin adds support for installing "Oh My ZSH" when adding new users.
|
||||||
|
|
||||||
|
To use it, add `adduser` to the plugins array of your `~/.zshrc` file:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
plugins=(... adduser)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Just run `adduser` as you normally would do and now:
|
||||||
|
|
||||||
|
1. The regular `adduser` command will run.
|
||||||
|
2. The shell of the new user will switch to zsh
|
||||||
|
3. "Oh My zsh will be installed (as if he would have ran `install.sh` himself).
|
||||||
|
|
||||||
|
## NOTES
|
||||||
|
|
||||||
|
- It is assumed that the last argument will be the username.<br>*(In rare cases people provide the group as last argument)*
|
||||||
|
- `useradd` behaviour is not changed.
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
|
[Nikolas Garofil](https://github.com/ngaro)
|
||||||
70
plugins/adduser/adduser.plugin.zsh
Normal file
70
plugins/adduser/adduser.plugin.zsh
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
# Copyright (c) 2021 Nikolas Garofil
|
||||||
|
|
||||||
|
_adduser_result() {
|
||||||
|
local result_string="Installation of 'Oh My Zsh' for '$new_user'"
|
||||||
|
|
||||||
|
#Erase the temporary copy of the installscript when necessary
|
||||||
|
if [[ ! -z $temp_installscript ]] ; then
|
||||||
|
rm $temp_installscript
|
||||||
|
fi
|
||||||
|
|
||||||
|
#mention the result
|
||||||
|
if [[ $1 -eq 0 ]]; then
|
||||||
|
echo "$result_string succeeded."
|
||||||
|
else
|
||||||
|
echo "$result_string failed." > /dev/stderr
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
adduser() {
|
||||||
|
local path_installscript="$ZSH/tools/install.sh"
|
||||||
|
local unattended_options=" --unattended"
|
||||||
|
|
||||||
|
local new_user=${@[$#]}
|
||||||
|
local temp_installscript; local unattended_installer; local install_as_user; local change_shell;
|
||||||
|
|
||||||
|
#Create user, errors will be reported by the 'real' adduser
|
||||||
|
#Don't use $new_user so that we have all args
|
||||||
|
command adduser $@ || return 1
|
||||||
|
|
||||||
|
echo "\nUser '$new_user' has been created. I will now try to install 'Oh My Zsh'"
|
||||||
|
|
||||||
|
if [[ ! -f $path_installscript ]] ; then
|
||||||
|
echo "Installationscript '$path_installscript' not available" > /dev/stderr;
|
||||||
|
_adduser_result 1
|
||||||
|
return 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
#copy install.sh to a new file in temp that we can give the right owner to execute
|
||||||
|
#and also make sure that after the install script we are no longer the new user
|
||||||
|
temp_installscript=$(mktemp)
|
||||||
|
cp $path_installscript $temp_installscript
|
||||||
|
chown $new_user $temp_installscript && chmod +x $temp_installscript
|
||||||
|
unattended_installer="$temp_installscript $unattended_options"
|
||||||
|
|
||||||
|
if [[ ( ! -x "$commands[sudo]" ) && ( ! -x "$commands[su]" ) ]] ; then
|
||||||
|
echo "You can't become $new_user (no 'sudo' or 'su' available)" > /dev/stderr;
|
||||||
|
_adduser_result 1
|
||||||
|
return 1;
|
||||||
|
fi
|
||||||
|
if [[ -x "$commands[sudo]" ]] ; then
|
||||||
|
install_as_user="sudo -u $new_user sh -c '$unattended_installer'"
|
||||||
|
change_shell="sudo chsh -s $commands[zsh] $new_user"
|
||||||
|
else
|
||||||
|
install_as_user="su -l $new_user -c '$unattended_installer'"
|
||||||
|
change_shell="su -c 'chsh -s $commands[zsh] $new_user'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
eval ${install_as_user}
|
||||||
|
#mention the result before changing the shell (even with a bad result it's still installed)
|
||||||
|
if [ ! $? -eq 0 ] ; then
|
||||||
|
_adduser_result 1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -x "$commands[chsh]" ]] ; then
|
||||||
|
echo "'chsh' is not available, change the shell manually." > /dev/stderr
|
||||||
|
fi
|
||||||
|
eval ${change_shell}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user