Skip to content

Commit bd20f02

Browse files
author
olevole
committed
fix perms for ~cbsd/nc.inventory file
historically cbsd requires root privileges (jail and bhyve restrictions that cant work from an unprivileged user). However, we try to use the "cbsd" user for some operations (rexe/remote nodes, some CBSD frontend) to not require root rights/access. Sice cbsd uses "002" umask, we are creating a 0400 perms for ~cbsd/nc.inventory which is always involved in the cbsd interpreter bootstrap. Pointed out: @almmos , fix for #782, Thanks!
1 parent 82edbf0 commit bd20f02

File tree

1 file changed

+44
-11
lines changed

1 file changed

+44
-11
lines changed

sudoexec/initenv

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -598,17 +598,21 @@ phase2()
598598
# todo: embed version to build and ask/check version before build
599599

600600
if [ ! -r ${distdir}/misc/sipcalc ]; then
601-
if [ -f ${distdir}/misc/src/sipcalc/Makefile ]; then
602-
make -C ${distdir}/misc/src/sipcalc
603-
installne "-o ${cbsduser} -g ${cbsduser} -m 555 -s" ${distdir}/misc/src/sipcalc/sipcalc ${distdir}/misc/sipcalc
604-
make -C ${distdir}/misc/src/sipcalc clean
601+
if [ ! -x ${distdir}/misc/sipcalc5 ]; then
602+
if [ -f ${distdir}/misc/src/sipcalc/Makefile ]; then
603+
make -C ${distdir}/misc/src/sipcalc
604+
installne "-o ${cbsduser} -g ${cbsduser} -m 555 -s" ${distdir}/misc/src/sipcalc/sipcalc ${distdir}/misc/sipcalc
605+
make -C ${distdir}/misc/src/sipcalc clean
606+
fi
605607
fi
606608
fi
607609

608610
if [ -f ${distdir}/misc/src/cbsd_md5/Makefile ]; then
609-
make -C ${distdir}/misc/src/cbsd_md5
610-
installne "-o ${cbsduser} -g ${cbsduser} -m 555 -s" ${distdir}/misc/src/cbsd_md5/cbsd_md5 ${distdir}/misc/cbsd_md5
611-
make -C ${distdir}/misc/src/cbsd_md5 clean
611+
if [ ! -x ${distdir}/misc/cbsd_md5 ]; then
612+
make -C ${distdir}/misc/src/cbsd_md5
613+
installne "-o ${cbsduser} -g ${cbsduser} -m 555 -s" ${distdir}/misc/src/cbsd_md5/cbsd_md5 ${distdir}/misc/cbsd_md5
614+
make -C ${distdir}/misc/src/cbsd_md5 clean
615+
fi
612616
fi
613617

614618
if [ ! -f ${distdir}/misc/ipv6range ]; then
@@ -913,7 +917,7 @@ phase5()
913917
exit 1
914918
fi
915919

916-
${CHMOD_CMD} 0660 ${dbdir}/inv.${nodename}.sqlite && ${CHOWN_CMD} ${cbsduser}:${cbsduser} ${dbdir}/inv.${nodename}.sqlite
920+
${CHMOD_CMD} 0660 ${dbdir}/inv.${nodename}.sqlite ${workdir}/nc.inventory && ${CHOWN_CMD} ${cbsduser}:${cbsduser} ${dbdir}/inv.${nodename}.sqlite ${workdir}/nc.inventory
917921

918922
env workdir=${workdir} /usr/local/bin/cbsd ${miscdir}/updatesql ${dbdir}/inv.${nodename}.sqlite ${distdir}/share/local-local.schema local
919923
env workdir=${workdir} /usr/local/bin/cbsd ${miscdir}/updatesql ${dbdir}/inv.${nodename}.sqlite ${distdir}/share/local-carp.schema carp
@@ -1514,7 +1518,7 @@ EOF
15141518

15151519
desc_question "preseedinit"
15161520
if [ $? -eq 0 -a "${answ}" = "1" ]; then
1517-
cp ${INITCFG_PRESEED} /tmp/prs.txt
1521+
${CP_CMD} ${INITCFG_PRESEED} /tmp/prs.txt
15181522

15191523
echo
15201524
echo "---cut here ---"
@@ -1523,11 +1527,40 @@ EOF
15231527
echo
15241528

15251529
fi
1526-
rm -f ${INITCFG_PRESEED}
1530+
${RM_CMD} -f ${INITCFG_PRESEED}
15271531

15281532
/usr/local/cbsd/misc/cbsdsysrc -qf ${workdir}/rc.conf preseedinit="${answ}" > /dev/null 2>&1
15291533
fi
15301534

1535+
if [ ${first_init} -eq 1 ]; then
1536+
[ -r /etc/rc.conf ] && . /etc/rc.conf
1537+
if [ "${cbsdd_enable}" = "YES" ]; then
1538+
printf "Starting service: cbsdd ... "
1539+
case "${platform}" in
1540+
Linux)
1541+
[ -z "${SYSTEMCTL_CMD}" ] && echo "no systemctl cmd" && break
1542+
${SYSTEMCTL_CMD} stop cbsdd.service > /dev/null 2>&1 || true
1543+
${SYSTEMCTL_CMD} start cbsdd.service > /dev/null 2>&1
1544+
_ret=$?
1545+
;;
1546+
*)
1547+
[ -z "${SERVICE_CMD}" ] && echo "no service cmd" && break
1548+
${SERVICE_CMD} cbsdd stop > /dev/null 2>&1 || true
1549+
${SERVICE_CMD} cbsdd start > /dev/null 2>&1
1550+
_ret=$?
1551+
;;
1552+
esac
1553+
case "${_ret}" in
1554+
0)
1555+
${ECHO} "${N2_COLOR}done${N0_COLOR}"
1556+
;;
1557+
1)
1558+
${ECHO} "${W1_COLOR}failed${N0_COLOR}"
1559+
;;
1560+
esac
1561+
fi
1562+
fi
1563+
15311564
exit 0
15321565
}
15331566

@@ -1655,7 +1688,7 @@ case "${platform}" in
16551688
true
16561689
;;
16571690
FreeBSD)
1658-
MAIN_EXTRA_CMD="${MAIN_EXTRA_CMD} kldstat pw"
1691+
MAIN_EXTRA_CMD="${MAIN_EXTRA_CMD} kldstat pw service"
16591692
;;
16601693
esac
16611694

0 commit comments

Comments
 (0)