Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install script does not properly escape shell special characters in arguments #3179

Closed
ShylajaDevadiga opened this issue Apr 12, 2021 · 3 comments
Assignees
Labels
kind/bug Something isn't working
Milestone

Comments

@ShylajaDevadiga
Copy link
Contributor

Environmental Info:
K3s Version:
v1.20.5-alpha1+k3s2 (881500d)

Node(s) CPU architecture, OS, and Version:
Ubuntu 20.04

Cluster Configuration:
Single node server with etcd backend

Describe the bug:
While creating scheduled snapshot install script does not honor passing of '*' for the cron parameter

Steps To Reproduce:

  1. Install k3s passing etcd snaphot flags as below with --etcd-snapshot-schedule-cron='*/1 * * * *'
curl -fL https://get.k3s.io | INSTALL_K3S_VERSION=v1.20.5-alpha1+k3s2 sh -s - server --cluster-init --etcd-s3 --etcd-s3-bucket=<bucket>  --etcd-snapshot-schedule-cron='*/1 * * * *'
  1. Systemd unit file contains invalid entry for the cronjob value as */1 a snap a snap a snap *
cat /etc/systemd/system/k3s.service
[Unit]
Description=Lightweight Kubernetes
Documentation=https://k3s.io
Wants=network-online.target
After=network-online.target

[Install]
WantedBy=multi-user.target

[Service]
Type=notify
EnvironmentFile=/etc/systemd/system/k3s.service.env
KillMode=process
Delegate=yes
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=1048576
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
TimeoutStartSec=0
Restart=always
RestartSec=5s
ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/k3s \
    server \
	'--cluster-init' \
	'--etcd-s3' \
	'--etcd-s3-bucket=<bucket naame>' \
	'--etcd-snapshot-schedule-cron=*/1 a snap a snap a snap *' \

Expected behavior:
Regex should recognize * as a literal when passed within ''

Actual behavior:
Regex in install script does not recognize '*' as a literal passed to cron job and replaces with invalid value

NOTE: Snapshot/Restore functionality is working as expected when executing k3s binary with same flags.

@ShylajaDevadiga ShylajaDevadiga added the kind/bug Something isn't working label Apr 12, 2021
@ShylajaDevadiga ShylajaDevadiga added this to the v1.20.6+k3s1 milestone Apr 12, 2021
@brandond brandond changed the title Install script does not honor asterisk * in the arguments passed Install script does properly escape shell special characters in arguments Apr 12, 2021
@davidnuzik davidnuzik modified the milestones: v1.20.6+k3s1, v1.20.7+k3s1 Apr 12, 2021
@dweomer dweomer changed the title Install script does properly escape shell special characters in arguments Install script does not properly escape shell special characters in arguments Apr 13, 2021
@davidnuzik davidnuzik assigned brandond and unassigned dweomer May 18, 2021
@davidnuzik
Copy link
Contributor

@brandond can review as he works on other install.sh script changes.

@davidnuzik
Copy link
Contributor

Fixing milestone. Fixing issue state @cjellick

@ShylajaDevadiga
Copy link
Contributor Author

Validated on v1.21.1+k3s1 shell special characters are interpreted correctly in the install script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants