Skip to content

Commit 194a5a0

Browse files
committed
Adding local-users-passwords-reset feature service, YANG model and its tests
1 parent af82081 commit 194a5a0

File tree

10 files changed

+94
-2
lines changed

10 files changed

+94
-2
lines changed

files/build_templates/docker_image_ctl.j2

-2
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,7 @@ start() {
540540
# TODO: Mellanox will remove the --tmpfs exception after SDK socket path changed in new SDK version
541541
{%- endif %}
542542
docker create {{docker_image_run_opt}} \
543-
{%- if '--net' not in docker_image_run_opt %}
544543
--net=$NET \
545-
{%- endif %}
546544
-e RUNTIME_OWNER=local \
547545
--uts=host \{# W/A: this should be set per-docker, for those dockers which really need host's UTS namespace #}
548546
{%- if install_debug_image == "y" %}

files/build_templates/init_cfg.json.j2

+5
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@
134134
"special_class": "true"
135135
}
136136
},
137+
"LOCAL_USERS_PASSWORDS_RESET": {
138+
"global": {
139+
"state": "disabled"
140+
}
141+
},
137142
"SYSTEM_DEFAULTS" : {
138143
{%- if include_mux == "y" %}
139144
"mux_tunnel_egress_acl": {

files/build_templates/sonic_debian_extension.j2

+5
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,11 @@ sudo cp $IMAGE_CONFIGS/hostname/hostname-config.service $FILESYSTEM_ROOT_USR_LIB
574574
echo "hostname-config.service" | sudo tee -a $GENERATED_SERVICE_FILE
575575
sudo cp $IMAGE_CONFIGS/hostname/hostname-config.sh $FILESYSTEM_ROOT/usr/bin/
576576

577+
# Copy local-users-passwords-reset configuration scripts
578+
sudo cp $IMAGE_CONFIGS/local-users-passwords-reset/local-users-passwords-reset.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
579+
echo "local-users-passwords-reset.service" | sudo tee -a $GENERATED_SERVICE_FILE
580+
sudo cp $IMAGE_CONFIGS/local-users-passwords-reset/local-users-passwords-reset.py $FILESYSTEM_ROOT/usr/bin/
581+
577582
# Copy miscellaneous scripts
578583
sudo cp $IMAGE_CONFIGS/misc/docker-wait-any $FILESYSTEM_ROOT/usr/bin/
579584

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python
2+
3+
import os
4+
import syslog
5+
6+
7+
SYSLOG_IDENTIFIER = os.path.basename(__file__)
8+
9+
10+
def log_info(msg):
11+
syslog.openlog(SYSLOG_IDENTIFIER)
12+
syslog.syslog(syslog.LOG_INFO, msg)
13+
syslog.closelog()
14+
15+
16+
def main():
17+
log_info("Azmy wrote this")
18+
19+
20+
if __name__ == "__main__":
21+
main()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=Update Local users' passwords config based on configdb
3+
Requires=config-setup.service
4+
After=config-setup.service
5+
Before=systemd-logind.service sshd.service getty.target [email protected]
6+
7+
8+
[Service]
9+
Type=oneshot
10+
RemainAfterExit=no
11+
ExecStart=/usr/bin/local-users-passwords-reset.py
12+
13+
[Install]
14+
WantedBy=sonic.target

src/sonic-yang-models/setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def run(self):
7979
data_files=[
8080
('yang-models', ['./yang-models/sonic-acl.yang',
8181
'./yang-models/sonic-auto_techsupport.yang',
82+
'./yang-models/sonic-local-users-passwords-reset',
8283
'./yang-models/sonic-bgp-common.yang',
8384
'./yang-models/sonic-bgp-device-global.yang',
8485
'./yang-models/sonic-bgp-global.yang',
@@ -192,6 +193,7 @@ def run(self):
192193
'./yang-models/sonic-macsec.yang',
193194
'./yang-models/sonic-bgp-sentinel.yang']),
194195
('cvlyang-models', ['./cvlyang-models/sonic-acl.yang',
196+
'./cvlyang-models/sonic-local-users-passwords-reset',
195197
'./cvlyang-models/sonic-bgp-common.yang',
196198
'./cvlyang-models/sonic-bgp-global.yang',
197199
'./cvlyang-models/sonic-bgp-monitor.yang',

src/sonic-yang-models/tests/files/sample_config_db.json

+5
Original file line numberDiff line numberDiff line change
@@ -2487,6 +2487,11 @@
24872487
}
24882488
}
24892489
},
2490+
"LOCAL_USERS_PASSWORDS_RESET": {
2491+
"global": {
2492+
"state": "disabled"
2493+
}
2494+
},
24902495
"SAMPLE_CONFIG_DB_UNKNOWN": {
24912496
"UNKNOWN_TABLE": {
24922497
"Error": "This Table is for testing, This Table does not have YANG models."
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"LOCAL_USERS_PASSWORDS_RESET_TEST_STATE": {
3+
"desc": "Configure Local users' passwords reset feature state."
4+
}
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"LOCAL_USERS_PASSWORDS_RESET_TEST_STATE": {
3+
"sonic-local-users-passwords-reset:sonic-local-users-passwords-reset": {
4+
"sonic-local-users-passwords-reset:LOCAL_USERS_PASSWORDS_RESET": {
5+
"global": {
6+
"state": "enabled"
7+
}
8+
}
9+
}
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module local-users-passwords-reset {
2+
yang-version 1.1;
3+
namespace "http://github.com/sonic-net/local-users-passwords-reset";
4+
5+
import sonic-types {
6+
prefix stypes;
7+
}
8+
9+
description "LONG_RESET_BUTTON YANG Module for SONiC-based OS";
10+
revision 2024-01-04 {
11+
description "First Revision";
12+
}
13+
14+
container sonic-local-users-passwords-reset {
15+
container LOCAL_USERS_PASSWORDS_RESET {
16+
description "LOCAL_USERS_PASSWORDS_RESET part of config_db.json";
17+
container global {
18+
leaf state {
19+
type stypes:admin_mode;
20+
description "Local users' passwords reset feature state";
21+
default disabled;
22+
}
23+
} /* end of container global */
24+
} /* end of container LOCAL_USERS_PASSWORDS_RESET */
25+
} /* end of top level container */
26+
}

0 commit comments

Comments
 (0)