oh-my-devpod 0.15.4 → 0.15.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/runtime/VERSION +1 -1
- package/runtime/bin/omd +0 -0
- package/runtime/build/omd-brew-provisioner.sh +85 -5
package/package.json
CHANGED
package/runtime/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.15.
|
|
1
|
+
0.15.5
|
package/runtime/bin/omd
CHANGED
|
Binary file
|
|
@@ -201,6 +201,14 @@ trusted_prefix_resolved() {
|
|
|
201
201
|
printf '%s\n' "${resolved}"
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
trusted_prefixes_equivalent() {
|
|
205
|
+
local first="$1" second="$2" first_resolved second_resolved
|
|
206
|
+
[[ "${first}" == /* && "${second}" == /* ]] || return 1
|
|
207
|
+
first_resolved="$(trusted_prefix_resolved "${first}")" || return 1
|
|
208
|
+
second_resolved="$(trusted_prefix_resolved "${second}")" || return 1
|
|
209
|
+
[[ "${first_resolved}" == "${second_resolved}" ]]
|
|
210
|
+
}
|
|
211
|
+
|
|
204
212
|
prepare_prefix_parent() {
|
|
205
213
|
if path_has_no_symlink_components "$(dirname "${prefix}")"; then
|
|
206
214
|
ensure_safe_parent "${prefix}"
|
|
@@ -502,24 +510,30 @@ write_inventory_record() {
|
|
|
502
510
|
}
|
|
503
511
|
|
|
504
512
|
legacy_formula_is_managed() {
|
|
505
|
-
local owner_home="$1" formula="$2" marker
|
|
513
|
+
local owner_home="$1" formula="$2" owner_uid="${3:-}" marker marker_prefix
|
|
506
514
|
marker="${owner_home}/.local/state/oh-my-devpod/managed/${formula}"
|
|
507
515
|
[[ -f "${marker}" && ! -L "${marker}" ]] || return 1
|
|
516
|
+
if [[ "${test_mode}" != "1" && -n "${owner_uid}" ]]; then
|
|
517
|
+
[[ "$(stat_uid "${marker}")" == "${owner_uid}" ]] || return 1
|
|
518
|
+
fi
|
|
508
519
|
grep -qx 'managed_by=oh-my-devpod' "${marker}" || return 1
|
|
520
|
+
grep -Fqx "component=${formula}" "${marker}" || return 1
|
|
509
521
|
grep -qx 'kind=brew-formula' "${marker}" || return 1
|
|
510
522
|
grep -Fqx "artifact=${formula}" "${marker}" || return 1
|
|
511
|
-
|
|
523
|
+
marker_prefix="$(sed -n 's/^brew_prefix=//p' "${marker}")"
|
|
524
|
+
[[ -n "${marker_prefix}" ]] || return 1
|
|
525
|
+
trusted_prefixes_equivalent "${marker_prefix}" "${prefix}"
|
|
512
526
|
}
|
|
513
527
|
|
|
514
528
|
stage_legacy_inventory() {
|
|
515
|
-
local owner_home="$1"
|
|
529
|
+
local owner_home="$1" owner_uid="$2" installation_id="$3" staging="$4" formula state provenance
|
|
516
530
|
mkdir -p "${staging}"
|
|
517
531
|
[[ -d "${prefix}/Cellar" ]] || return 0
|
|
518
532
|
while IFS= read -r formula; do
|
|
519
533
|
[[ -n "${formula}" ]] || continue
|
|
520
534
|
state=external
|
|
521
535
|
provenance=legacy-preexisting
|
|
522
|
-
if legacy_formula_is_managed "${owner_home}" "${formula}"; then
|
|
536
|
+
if legacy_formula_is_managed "${owner_home}" "${formula}" "${owner_uid}"; then
|
|
523
537
|
state=managed
|
|
524
538
|
provenance=legacy-marker
|
|
525
539
|
fi
|
|
@@ -527,6 +541,71 @@ stage_legacy_inventory() {
|
|
|
527
541
|
done < <(find "${prefix}/Cellar" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | LC_ALL=C sort -u)
|
|
528
542
|
}
|
|
529
543
|
|
|
544
|
+
legacy_inventory_record_is_recoverable() {
|
|
545
|
+
local record="$1" formula="$2" installation_id="$3"
|
|
546
|
+
[[ -f "${record}" && ! -L "${record}" ]] || return 1
|
|
547
|
+
grep -qx 'managed_by=oh-my-devpod' "${record}" || return 1
|
|
548
|
+
grep -Fqx "component=${formula}" "${record}" || return 1
|
|
549
|
+
grep -qx 'kind=brew-formula' "${record}" || return 1
|
|
550
|
+
grep -Fqx "artifact=${formula}" "${record}" || return 1
|
|
551
|
+
grep -Fqx "brew_prefix=${prefix}" "${record}" || return 1
|
|
552
|
+
grep -Fqx "installation_id=${installation_id}" "${record}" || return 1
|
|
553
|
+
grep -qx 'state=external' "${record}" || return 1
|
|
554
|
+
grep -qx 'provenance=legacy-preexisting' "${record}"
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
member_identity_for_recovery() {
|
|
558
|
+
local record="$1" user uid home mode current_uid current_home
|
|
559
|
+
[[ -f "${record}" && ! -L "${record}" ]] || return 1
|
|
560
|
+
user="$(basename "${record}")"
|
|
561
|
+
valid_account_name "${user}" || return 1
|
|
562
|
+
if [[ "${test_mode}" != "1" ]]; then
|
|
563
|
+
[[ "$(stat_uid "${record}")" == "0" && "$(stat_gid "${record}")" == "0" ]] || return 1
|
|
564
|
+
mode="$(stat_mode "${record}")" || return 1
|
|
565
|
+
[[ "${mode}" =~ ^[0-7]{3,4}$ ]] || return 1
|
|
566
|
+
(( (8#${mode} & 8#022) == 0 )) || return 1
|
|
567
|
+
fi
|
|
568
|
+
grep -qx 'managed_by=oh-my-devpod' "${record}" || return 1
|
|
569
|
+
grep -Fqx "user=${user}" "${record}" || return 1
|
|
570
|
+
uid="$(sed -n 's/^uid=//p' "${record}")"
|
|
571
|
+
home="$(sed -n 's/^home=//p' "${record}")"
|
|
572
|
+
[[ "${uid}" =~ ^[0-9]+$ ]] || return 1
|
|
573
|
+
[[ "${home}" == /* && -d "${home}" && ! -L "${home}" ]] || return 1
|
|
574
|
+
if [[ "${test_mode}" != "1" ]]; then
|
|
575
|
+
current_uid="$(id -u "${user}" 2>/dev/null)" || return 1
|
|
576
|
+
current_home="$(passwd_home "${user}")"
|
|
577
|
+
[[ "${uid}" == "${current_uid}" && "${home}" == "${current_home}" ]] || return 1
|
|
578
|
+
fi
|
|
579
|
+
printf '%s\t%s\n' "${uid}" "${home}"
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
recover_legacy_inventory() {
|
|
583
|
+
local installation_id service_uid service_gid record formula member identity member_uid member_home recovered
|
|
584
|
+
installation_id="$(manifest_value installation_id || true)"
|
|
585
|
+
[[ -n "${installation_id}" ]] || return 0
|
|
586
|
+
service_uid="$(account_uid "${service_user}")"
|
|
587
|
+
service_gid="$(group_gid "${manager_group}")"
|
|
588
|
+
while IFS= read -r -d '' record; do
|
|
589
|
+
formula="$(basename "${record}")"
|
|
590
|
+
valid_formula_name "${formula}" || continue
|
|
591
|
+
legacy_inventory_record_is_recoverable "${record}" "${formula}" "${installation_id}" || continue
|
|
592
|
+
while IFS= read -r -d '' member; do
|
|
593
|
+
identity="$(member_identity_for_recovery "${member}" || true)"
|
|
594
|
+
[[ -n "${identity}" ]] || continue
|
|
595
|
+
IFS=$'\t' read -r member_uid member_home <<< "${identity}"
|
|
596
|
+
legacy_formula_is_managed "${member_home}" "${formula}" "${member_uid}" || continue
|
|
597
|
+
recovered="${inventory_dir}/.${formula}.recovered.$$"
|
|
598
|
+
write_inventory_record "${formula}" "${installation_id}" managed legacy-marker-recovered "${recovered}"
|
|
599
|
+
chmod 0644 "${recovered}"
|
|
600
|
+
if [[ "${test_mode}" != "1" ]]; then
|
|
601
|
+
chown "${service_uid}:${service_gid}" "${recovered}"
|
|
602
|
+
fi
|
|
603
|
+
mv -f "${recovered}" "${record}"
|
|
604
|
+
break
|
|
605
|
+
done < <(find "${members_dir}" -mindepth 1 -maxdepth 1 -type f -print0)
|
|
606
|
+
done < <(find "${inventory_dir}" -mindepth 1 -maxdepth 1 -type f -print0)
|
|
607
|
+
}
|
|
608
|
+
|
|
530
609
|
write_manifest() {
|
|
531
610
|
local mirror_profile="$1" installation_id="$2" service_uid="$3" service_gid="$4" destination="$5" resolved_prefix
|
|
532
611
|
resolved_prefix="$(trusted_prefix_resolved "${prefix}")" || fail "shared Brew prefix path is not trusted"
|
|
@@ -593,7 +672,7 @@ initialize_shared_state() {
|
|
|
593
672
|
if [[ -e "${prefix}" || -L "${prefix}" ]]; then
|
|
594
673
|
legacy_info="$(validate_legacy_prefix)"
|
|
595
674
|
IFS=$'\t' read -r legacy_owner legacy_uid legacy_gid legacy_home <<< "${legacy_info}"
|
|
596
|
-
stage_legacy_inventory "${legacy_home}" "${installation_id}" "${inventory_staging}"
|
|
675
|
+
stage_legacy_inventory "${legacy_home}" "${legacy_uid}" "${installation_id}" "${inventory_staging}"
|
|
597
676
|
else
|
|
598
677
|
created_prefix=1
|
|
599
678
|
if ! initialize_prefix "${mirror_profile}"; then
|
|
@@ -844,6 +923,7 @@ ensure_shared_brew() {
|
|
|
844
923
|
fi
|
|
845
924
|
rm -f "${state_dir}/.legacy-owner"
|
|
846
925
|
fi
|
|
926
|
+
recover_legacy_inventory
|
|
847
927
|
}
|
|
848
928
|
|
|
849
929
|
case "${1:-}" in
|