Initial commit
Some checks failed
Build Kernel / Build all affected Kernels (push) Has been cancelled
Build all core packages / Build all core packages for selected target (push) Has been cancelled
Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
Build Toolchains / Build Toolchains for each target (push) Has been cancelled
Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
Coverity scan build / Coverity x86/64 build (push) Has been cancelled

This commit is contained in:
domenico
2025-06-24 12:51:15 +02:00
commit 27c9d80f51
10493 changed files with 1885777 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org
START=50
USE_PROCD=1
PROG=/usr/sbin/crond
validate_cron_section() {
uci_validate_section system system "${1}" \
'cronloglevel:uinteger'
}
start_service() {
[ -z "$(ls /etc/crontabs/)" ] && return 1
loglevel="$(uci_get "system.@system[0].cronloglevel")"
[ -z "${loglevel}" ] || {
/sbin/validate_data uinteger "${loglevel}" 2>/dev/null
[ "$?" -eq 0 ] || {
echo "validation failed"
return 1
}
}
mkdir -p /var/spool/cron
ln -s /etc/crontabs /var/spool/cron/ 2>/dev/null
procd_open_instance
procd_set_param command "$PROG" -f -c /etc/crontabs -l "${loglevel:-5}"
for crontab in /etc/crontabs/*; do
procd_set_param file "$crontab"
done
procd_set_param respawn
procd_close_instance
}
service_triggers() {
procd_add_validation validate_cron_section
}

View File

@@ -0,0 +1,12 @@
#!/bin/sh
. /usr/share/libubox/jshn.sh
addenv="$( env | while read line; do echo "json_add_string \"\" \"$line\";"; done )"
json_init
json_add_array env
json_add_string "" "ACTION=$1"
eval "$addenv"
json_close_array env
ubus call hotplug.ntp call "$(json_dump)"

View File

@@ -0,0 +1,22 @@
{
"bounding": [
"CAP_NET_BIND_SERVICE",
"CAP_SYS_TIME"
],
"effective": [
"CAP_NET_BIND_SERVICE",
"CAP_SYS_TIME"
],
"ambient": [
"CAP_NET_BIND_SERVICE",
"CAP_SYS_TIME"
],
"permitted": [
"CAP_NET_BIND_SERVICE",
"CAP_SYS_TIME"
],
"inheritable": [
"CAP_NET_BIND_SERVICE",
"CAP_SYS_TIME"
]
}

View File

@@ -0,0 +1,8 @@
{
"user": "ntp",
"access": {
"hotplug.ntp": {
"methods": [ "call" ]
}
}
}

View File

@@ -0,0 +1,130 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2011 OpenWrt.org
START=98
USE_PROCD=1
PROG=/usr/sbin/ntpd
HOTPLUG_SCRIPT=/usr/sbin/ntpd-hotplug
get_dhcp_ntp_servers() {
local interfaces="$1"
local filter="*"
local interface ntpservers ntpserver
for interface in $interfaces; do
[ "$filter" = "*" ] && filter="@.interface='$interface'" || filter="$filter,@.interface='$interface'"
done
ntpservers=$(ubus call network.interface dump | jsonfilter -e "@.interface[$filter]['data']['ntpserver']")
for ntpserver in $ntpservers; do
local duplicate=0
local entry
for entry in $server; do
[ "$ntpserver" = "$entry" ] && duplicate=1
done
[ "$duplicate" = 0 ] && server="$server $ntpserver"
done
}
validate_ntp_section() {
uci_load_validate system timeserver "$1" "$2" \
'dhcp_interface:list(string)' \
'enable_server:bool:0' \
'enabled:bool:1' \
'interface:string' \
'server:list(host)' \
'use_dhcp:bool:1'
}
start_ntpd_instance() {
local peer
[ "$2" = 0 ] || {
echo "validation failed"
return 1
}
[ $enabled = 0 ] && return
[ $use_dhcp = 1 ] && get_dhcp_ntp_servers "$dhcp_interface"
[ -z "$server" -a "$enable_server" = "0" ] && return
procd_open_instance
procd_set_param command "$PROG" -n -N
if [ "$enable_server" = "1" ]; then
procd_append_param command -l
[ -n "$interface" ] && {
local ifname
network_get_device ifname "$interface" || \
ifname="$interface"
procd_append_param command -I "$ifname"
procd_append_param netdev "$ifname"
}
fi
[ -x "$HOTPLUG_SCRIPT" ] && procd_append_param command -S "$HOTPLUG_SCRIPT"
for peer in $server; do
procd_append_param command -p $peer
done
procd_set_param respawn
[ -x /sbin/ujail -a -e /etc/capabilities/ntpd.json ] && {
procd_add_jail ntpd ubus
procd_add_jail_mount "$HOTPLUG_SCRIPT"
procd_add_jail_mount "/usr/share/libubox/jshn.sh"
procd_add_jail_mount "/usr/bin/env"
procd_add_jail_mount "/usr/bin/jshn"
procd_add_jail_mount "/bin/ubus"
procd_set_param capabilities /etc/capabilities/ntpd.json
procd_set_param user ntp
procd_set_param group ntp
procd_set_param no_new_privs 1
}
procd_close_instance
}
start_service() {
. /lib/functions/network.sh
validate_ntp_section ntp start_ntpd_instance
}
service_triggers() {
local script name use_dhcp enable_server interface
script=$(readlink -f "$initscript")
name=$(basename ${script:-$initscript})
procd_add_config_trigger "config.change" "system" /etc/init.d/$name reload
config_load system
config_get use_dhcp ntp use_dhcp 1
[ $use_dhcp = 1 ] && {
local dhcp_interface
config_get dhcp_interface ntp dhcp_interface
if [ -n "$dhcp_interface" ]; then
for n in $dhcp_interface; do
procd_add_interface_trigger "interface.*" $n /etc/init.d/$name reload
done
else
procd_add_raw_trigger "interface.*" 1000 /etc/init.d/$name reload
fi
}
config_get_bool enable_server ntp enable_server 0
config_get interface ntp interface
[ $enable_server -eq 1 ] && [ -n "$interface" ] && {
local ifname
network_get_device ifname "$interface" || \
ifname="$interface"
procd_add_interface_trigger "interface.*" "$ifname" \
/etc/init.d/"$name" reload
}
procd_add_validation validate_ntp_section
}