mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2026-08-28 11:56:03 +00:00
fix: Make failed chown non-fatal (#1265)
This commit is contained in:
@@ -634,7 +634,6 @@ addDisk () {
|
||||
if [ -f "$DISK_FILE" ]; then
|
||||
if ! setOwner "$DISK_FILE"; then
|
||||
error "Failed to set the owner for \"$DISK_FILE\" !"
|
||||
exit 77
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
+10
-7
@@ -1495,23 +1495,26 @@ configureMAC() {
|
||||
container=$(containerID)
|
||||
|
||||
if [ -z "$MAC" ]; then
|
||||
|
||||
file="$STORAGE/dsm.mac"
|
||||
[ -s "$file" ] && MAC=$(<"$file")
|
||||
MAC="${MAC//[![:print:]]/}"
|
||||
|
||||
if [ -s "$file" ]; then
|
||||
if ! MAC=$(readFile "$file"); then
|
||||
error "Failed to read MAC address from \"$file\" !"
|
||||
exit 28
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$MAC" ]; then
|
||||
|
||||
# Generate a Synology-style MAC address based on a stable container identifier when possible.
|
||||
MAC=$(echo "$container" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:11:32:\3:\4:\5/')
|
||||
|
||||
if ! echo "${MAC^^}" > "$file"; then
|
||||
if ! writeFile "${MAC^^}" "$file"; then
|
||||
error "Failed to write MAC address to \"$file\" !"
|
||||
exit 28
|
||||
fi
|
||||
|
||||
if ! setOwner "$file"; then
|
||||
error "Failed to set the owner for \"$file\" !"
|
||||
exit 28
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
+2
-3
@@ -248,14 +248,13 @@ writeFile() {
|
||||
local txt="$1"
|
||||
local path="$2"
|
||||
|
||||
if ! printf '%s\n' "$txt" >"$path"; then
|
||||
if ! printf '%s\n' "$txt" > "$path"; then
|
||||
error "Failed to write file \"$path\" !"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! setOwner "$path"; then
|
||||
error "Failed to set the owner for \"$path\" !"
|
||||
return 1
|
||||
warn "failed to set the owner for \"$path\"."
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user