Skip to content

Commit 1d59d43

Browse files
authored
Merge pull request #5255 from acmesh-official/dev
sync
2 parents 0f61e9c + fe30bf7 commit 1d59d43

File tree

5 files changed

+37
-22
lines changed

5 files changed

+37
-22
lines changed

.github/workflows/PebbleStrict.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: Install tools
3838
run: sudo apt-get install -y socat
3939
- name: Run Pebble
40-
run: cd .. && curl https://raw.githubusercontent.com/letsencrypt/pebble/master/docker-compose.yml >docker-compose.yml && docker-compose up -d
40+
run: cd .. && curl https://raw.githubusercontent.com/letsencrypt/pebble/master/docker-compose.yml >docker-compose.yml && docker compose up -d
4141
- name: Set up Pebble
4242
run: curl --request POST --data '{"ip":"10.30.50.1"}' http://localhost:8055/set-default-ipv4
4343
- name: Clone acmetest

acme.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -3881,6 +3881,9 @@ updateaccount() {
38813881
if [ "$code" = '200' ]; then
38823882
echo "$response" >"$ACCOUNT_JSON_PATH"
38833883
_info "Account update success for $_accUri."
3884+
3885+
ACCOUNT_THUMBPRINT="$(__calc_account_thumbprint)"
3886+
_info "ACCOUNT_THUMBPRINT" "$ACCOUNT_THUMBPRINT"
38843887
else
38853888
_info "An error occurred and the account was not updated."
38863889
return 1
@@ -7139,7 +7142,7 @@ _processAccountConf() {
71397142
}
71407143

71417144
_checkSudo() {
7142-
if [ -z "__INTERACTIVE" ]; then
7145+
if [ -z "$__INTERACTIVE" ]; then
71437146
#don't check if it's not in an interactive shell
71447147
return 0
71457148
fi

deploy/routeros.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ routeros_deploy() {
137137
return $_err_code
138138
fi
139139

140-
DEPLOY_SCRIPT_CMD="/system script add name=\"LECertDeploy-$_cdomain\" owner=$ROUTER_OS_USERNAME \
140+
DEPLOY_SCRIPT_CMD=":do {/system script remove \"LECertDeploy-$_cdomain\" } on-error={ }; \
141+
/system script add name=\"LECertDeploy-$_cdomain\" owner=$ROUTER_OS_USERNAME \
141142
comment=\"generated by routeros deploy script in acme.sh\" \
142143
source=\"/certificate remove [ find name=$_cdomain.cer_0 ];\
143144
\n/certificate remove [ find name=$_cdomain.cer_1 ];\
@@ -146,8 +147,8 @@ source=\"/certificate remove [ find name=$_cdomain.cer_0 ];\
146147
\n/certificate import file-name=$_cdomain.cer passphrase=\\\"\\\";\
147148
\n/certificate import file-name=$_cdomain.key passphrase=\\\"\\\";\
148149
\ndelay 1;\
149-
\n/file remove $_cdomain.cer;\
150-
\n/file remove $_cdomain.key;\
150+
\n:do {/file remove $_cdomain.cer; } on-error={ }\
151+
\n:do {/file remove $_cdomain.key; } on-error={ }\
151152
\ndelay 2;\
152153
\n/ip service set www-ssl certificate=$_cdomain.cer_0;\
153154
\n$ROUTER_OS_ADDITIONAL_SERVICES;\

deploy/synology_dsm.sh

+27-16
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
################################################################################
4040
# Dependencies:
4141
# - curl
42-
# - synouser & synogroup (When available and SYNO_USE_TEMP_ADMIN is set)
42+
# - synouser & synogroup & synosetkeyvalue (Required for SYNO_USE_TEMP_ADMIN=1)
4343
################################################################################
4444
# Return value:
4545
# 0 means success, otherwise error.
@@ -66,14 +66,18 @@ synology_dsm_deploy() {
6666
_getdeployconf SYNO_DEVICE_NAME
6767

6868
# Prepare to use temp admin if SYNO_USE_TEMP_ADMIN is set
69-
_debug2 SYNO_USE_TEMP_ADMIN "$SYNO_USE_TEMP_ADMIN"
7069
_getdeployconf SYNO_USE_TEMP_ADMIN
7170
_check2cleardeployconfexp SYNO_USE_TEMP_ADMIN
7271
_debug2 SYNO_USE_TEMP_ADMIN "$SYNO_USE_TEMP_ADMIN"
7372

7473
if [ -n "$SYNO_USE_TEMP_ADMIN" ]; then
75-
if ! _exists synouser || ! _exists synogroup; then
76-
_err "Tools are missing for creating temp admin user, please set SYNO_USERNAME and SYNO_PASSWORD instead."
74+
if ! _exists synouser || ! _exists synogroup || ! _exists synosetkeyvalue; then
75+
_err "Missing required tools to creat temp admin user, please set SYNO_USERNAME and SYNO_PASSWORD instead."
76+
_err "Notice: temp admin user authorization method only supports local deployment on DSM."
77+
return 1
78+
fi
79+
if synouser --help 2>&1 | grep -q 'Permission denied'; then
80+
_err "For creating temp admin user, the deploy script must be run as root."
7781
return 1
7882
fi
7983

@@ -169,7 +173,7 @@ synology_dsm_deploy() {
169173
_debug3 H1 "${_H1}"
170174
fi
171175

172-
response=$(_post "method=login&account=$encoded_username&passwd=$encoded_password&api=SYNO.API.Auth&version=$api_version&enable_syno_token=yes&otp_code=$DEPRECATED_otp_code&device_name=certrenewal&device_id=$SYNO_DEVICE_ID" "$_base_url/webapi/auth.cgi?enable_syno_token=yes")
176+
response=$(_post "method=login&account=$encoded_username&passwd=$encoded_password&api=SYNO.API.Auth&version=$api_version&enable_syno_token=yes&otp_code=$DEPRECATED_otp_code&device_name=certrenewal&device_id=$SYNO_DEVICE_ID" "$_base_url/webapi/$api_path?enable_syno_token=yes")
173177
_debug3 response "$response"
174178
# ## END ## - DEPRECATED, for backward compatibility
175179
# If SYNO_DEVICE_ID or SYNO_OTP_CODE is set, we treat current account enabled 2FA-OTP.
@@ -184,7 +188,7 @@ synology_dsm_deploy() {
184188
_debug SYNO_LOCAL_HOSTNAME "${SYNO_LOCAL_HOSTNAME:-}"
185189
if [ "$SYNO_LOCAL_HOSTNAME" != "1" ] && [ "$SYNO_LOCAL_HOSTNAME" == "$SYNO_HOSTNAME" ]; then
186190
if [ "$SYNO_HOSTNAME" != "localhost" ] && [ "$SYNO_HOSTNAME" != "127.0.0.1" ]; then
187-
_err "SYNO_USE_TEMP_ADMIN=1 Only support locally deployment, if you are sure that hostname $SYNO_HOSTNAME is targeting to your **current local machine**, execute 'export SYNO_LOCAL_HOSTNAME=1' then rerun."
191+
_err "SYNO_USE_TEMP_ADMIN=1 only support local deployment, though if you are sure that the hostname $SYNO_HOSTNAME is targeting to your **current local machine**, execute 'export SYNO_LOCAL_HOSTNAME=1' then rerun."
188192
return 1
189193
fi
190194
fi
@@ -201,24 +205,27 @@ synology_dsm_deploy() {
201205
# shellcheck disable=SC2086
202206
synogroup --member administrators $cur_admins $SYNO_USERNAME >/dev/null
203207
else
204-
_err "Tool synogroup may be broken, please set SYNO_USERNAME and SYNO_PASSWORD instead."
208+
_err "The tool synogroup may be broken, please set SYNO_USERNAME and SYNO_PASSWORD instead."
205209
return 1
206210
fi
207211
else
208212
_err "Unsupported synogroup tool detected, please set SYNO_USERNAME and SYNO_PASSWORD instead."
209213
return 1
210214
fi
211-
# havig a workaround to temporary disable enforce 2FA-OTP
215+
# havig a workaround to temporary disable enforce 2FA-OTP, will restore
216+
# it soon (after a single request), though if any accident occurs like
217+
# unexpected interruption, this setting can be easily reverted manually.
212218
otp_enforce_option=$(synogetkeyvalue /etc/synoinfo.conf otp_enforce_option)
213219
if [ -n "$otp_enforce_option" ] && [ "${otp_enforce_option:-"none"}" != "none" ]; then
214220
synosetkeyvalue /etc/synoinfo.conf otp_enforce_option none
215-
_info "Temporary disabled enforce 2FA-OTP to complete authentication."
221+
_info "Enforcing 2FA-OTP has been disabled to complete temp admin authentication."
222+
_info "Notice: it will be restored soon, if not, you can restore it manually via Control Panel."
216223
_info "previous_otp_enforce_option" "$otp_enforce_option"
217224
else
218225
otp_enforce_option=""
219226
fi
220227
fi
221-
response=$(_get "$_base_url/webapi/entry.cgi?api=SYNO.API.Auth&version=$api_version&method=login&format=sid&account=$encoded_username&passwd=$encoded_password&enable_syno_token=yes")
228+
response=$(_get "$_base_url/webapi/$api_path?api=SYNO.API.Auth&version=$api_version&method=login&format=sid&account=$encoded_username&passwd=$encoded_password&enable_syno_token=yes")
222229
if [ -n "$SYNO_USE_TEMP_ADMIN" ] && [ -n "$otp_enforce_option" ]; then
223230
synosetkeyvalue /etc/synoinfo.conf otp_enforce_option "$otp_enforce_option"
224231
_info "Restored previous enforce 2FA-OTP option."
@@ -230,7 +237,7 @@ synology_dsm_deploy() {
230237
error_code=$(echo "$response" | grep '"error":' | grep -o '"code":[0-9]*' | grep -o '[0-9]*')
231238
_debug2 error_code "$error_code"
232239
# Account has 2FA-OTP enabled, since error 403 reported.
233-
# https://global.download.synology.com/download/Document/Software/DeveloperGuide/Firmware/DSM/All/enu/Synology_DiskStation_Administration_CLI_Guide.pdf
240+
# https://global.download.synology.com/download/Document/Software/DeveloperGuide/Os/DSM/All/enu/DSM_Login_Web_API_Guide_enu.pdf
234241
if [ "$error_code" == "403" ]; then
235242
if [ -z "$SYNO_DEVICE_NAME" ]; then
236243
printf "Enter device name or leave empty for default (CertRenewal): "
@@ -274,12 +281,16 @@ synology_dsm_deploy() {
274281
_err "Failed to authenticate with provided 2FA-OTP code, please try again in a new terminal window."
275282
elif [ "$error_code" == "406" ]; then
276283
if [ -n "$SYNO_USE_TEMP_ADMIN" ]; then
277-
_err "SYNO_USE_TEMP_ADMIN=1 is not supported if enforce auth with 2FA-OTP is enabled."
284+
_err "Failed with unexcepted error, please report this by providing full log with '--debug 3'."
278285
else
279286
_err "Enforce auth with 2FA-OTP enabled, please configure the user to enable 2FA-OTP to continue."
280287
fi
281-
elif [ "$error_code" == "400" ] || [ "$error_code" == "401" ] || [ "$error_code" == "408" ] || [ "$error_code" == "409" ] || [ "$error_code" == "410" ]; then
282-
_err "Failed to authenticate with a non-existent or disabled account, or the account password is incorrect or has expired."
288+
elif [ "$error_code" == "400" ]; then
289+
_err "Failed to authenticate, no such account or incorrect password."
290+
elif [ "$error_code" == "401" ]; then
291+
_err "Failed to authenticate with a non-existent account."
292+
elif [ "$error_code" == "408" ] || [ "$error_code" == "409" ] || [ "$error_code" == "410" ]; then
293+
_err "Failed to authenticate, the account password has expired or must be changed."
283294
else
284295
_err "Failed to authenticate with error: $error_code."
285296
fi
@@ -293,7 +304,7 @@ synology_dsm_deploy() {
293304
_debug SynoToken "$token"
294305
if [ -z "$sid" ] || [ -z "$token" ]; then
295306
# Still can't get necessary info even got no errors, may Synology have API updated?
296-
_err "Unable to authenticate to $_base_url, you may report the full log to the community."
307+
_err "Unable to authenticate to $_base_url, you may report this by providing full log with '--debug 3'."
297308
_temp_admin_cleanup "$SYNO_USE_TEMP_ADMIN" "$SYNO_USERNAME"
298309
return 1
299310
fi
@@ -331,7 +342,7 @@ synology_dsm_deploy() {
331342
if [ "$error_code" -eq 105 ]; then
332343
_err "Current user is not administrator and does not have sufficient permission for deploying."
333344
else
334-
_err "Failed to fetch certificate info with error: $error_code, please try again or contact Synology to learn more."
345+
_err "Failed to fetch certificate info: $error_code, please try again or contact Synology to learn more."
335346
fi
336347
_temp_admin_cleanup "$SYNO_USE_TEMP_ADMIN" "$SYNO_USERNAME"
337348
return 1

dnsapi/dns_porkbun.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ dns_porkbun_rm() {
9393
_err "Delete record error."
9494
return 1
9595
fi
96-
echo "$response" | tr -d " " | grep '\"status\":"SUCCESS"' >/dev/null
96+
echo "$response" | tr -d " " | grep '"status":"SUCCESS"' >/dev/null
9797
fi
9898

9999
}

0 commit comments

Comments
 (0)