mirror of
https://github.com/clearlinux/micro-config-drive.git
synced 2026-04-28 10:53:47 +00:00
auto-prepend username to sudo directives
update users.yaml example
This commit is contained in:
@@ -18,6 +18,6 @@ users:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmHRP+1o+vBSg+ej714Y3iO5Osbr29dHL/WZQlsj
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9GNA2I6IU+II1qoKP1Ttn/eNv8zquEDNii+EA5m
|
||||
sudo:
|
||||
- [ "ALL ALL=(ALL) NOPASSWD:ALL", "ALL ALL=(ALL) NOPASSWD:/bin/mysql" ]
|
||||
- ALL ALL=(ALL) NOPASSWD:ALL
|
||||
- [ "ALL=(ALL) NOPASSWD:ALL", "ALL=(ALL) NOPASSWD:/bin/mysql" ]
|
||||
- ALL=(ALL) NOPASSWD:ALL
|
||||
system: true
|
||||
|
||||
@@ -125,7 +125,8 @@ static void users_add_option(GNode* node, GString* command, gpointer data) {
|
||||
}
|
||||
|
||||
static gboolean users_sudo_item(GNode* node, gpointer data) {
|
||||
g_string_append_printf((GString*)data, "%s\n", (char*)node->data);
|
||||
g_string_append_printf((GString*)data, "%s %s\n", users_current_username,
|
||||
(char*)node->data);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -209,11 +210,13 @@ static void users_item(GNode* node, gpointer data) {
|
||||
item = cloud_config_find(node, SUDO);
|
||||
if (item) {
|
||||
sudo_directives = g_string_new("");
|
||||
g_string_printf(sudo_directives, "# User rules\n");
|
||||
g_string_printf(sudo_directives, "# Rules for %s user\n",
|
||||
users_current_username);
|
||||
g_node_traverse(item->parent, G_IN_ORDER, G_TRAVERSE_LEAVES,
|
||||
-1, users_sudo_item, sudo_directives);
|
||||
g_string_append(sudo_directives, "\n");
|
||||
if (!write_sudo_directives(sudo_directives, "users-cloud-init", O_CREAT|O_APPEND|O_WRONLY)) {
|
||||
if (!write_sudo_directives(sudo_directives, "users-cloud-init",
|
||||
O_CREAT|O_APPEND|O_WRONLY)) {
|
||||
LOG(MOD "Cannot write sudo directives\n");
|
||||
}
|
||||
g_string_free(sudo_directives, true);
|
||||
|
||||
Reference in New Issue
Block a user