Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SSH Manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
network
SSH Manager
Commits
c56a09b2
Commit
c56a09b2
authored
1 year ago
by
Rahul Thakur
Browse files
Options
Downloads
Plain Diff
Merge branch 'align_dm_data' into 'devel'
Align with dm_data See merge request
!7
parents
790689b6
f8b8bee1
No related branches found
No related tags found
1 merge request
!7
Align with dm_data
Pipeline
#155772
passed
1 year ago
Stage: static_code_analysis
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sshmngr.c
+17
-20
17 additions, 20 deletions
src/sshmngr.c
with
17 additions
and
20 deletions
src/sshmngr.c
+
17
−
20
View file @
c56a09b2
...
@@ -179,9 +179,9 @@ static int delObjSSHKey(char *refparam, struct dmctx *ctx, void *data, char *ins
...
@@ -179,9 +179,9 @@ static int delObjSSHKey(char *refparam, struct dmctx *ctx, void *data, char *ins
switch
(
del_action
)
{
switch
(
del_action
)
{
case
DEL_INST
:
case
DEL_INST
:
dmuci_get_value_by_section_string
((
struct
uci_section
*
)
data
,
"pubkey"
,
&
value
);
dmuci_get_value_by_section_string
((
(
struct
dm_data
*
)
data
)
->
dmmap_section
,
"pubkey"
,
&
value
);
remove_pubkey
(
value
);
remove_pubkey
(
value
);
dmuci_delete_by_section
((
struct
uci_section
*
)
data
,
NULL
,
NULL
);
dmuci_delete_by_section
((
(
struct
dm_data
*
)
data
)
->
dmmap_section
,
NULL
,
NULL
);
break
;
break
;
case
DEL_ALL
:
case
DEL_ALL
:
uci_path_foreach_sections_safe
(
bbfdm
,
"dmmap_sshmngr"
,
"authkey"
,
stmp
,
s
)
{
uci_path_foreach_sections_safe
(
bbfdm
,
"dmmap_sshmngr"
,
"authkey"
,
stmp
,
s
)
{
...
@@ -248,6 +248,7 @@ static int browseSSHKeyInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev
...
@@ -248,6 +248,7 @@ static int browseSSHKeyInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev
char
*
key
=
NULL
;
char
*
key
=
NULL
;
unsigned
idx
=
0
;
unsigned
idx
=
0
;
json_object
*
json_key_list
=
NULL
,
*
arr_obj
=
NULL
;
json_object
*
json_key_list
=
NULL
,
*
arr_obj
=
NULL
;
struct
dm_data
data
=
{
0
};
dmubus_call
(
"sshmngr"
,
"list_keys"
,
UBUS_ARGS
{
0
},
0
,
&
json_key_list
);
dmubus_call
(
"sshmngr"
,
"list_keys"
,
UBUS_ARGS
{
0
},
0
,
&
json_key_list
);
DM_ASSERT
(
json_key_list
,
return
0
);
DM_ASSERT
(
json_key_list
,
return
0
);
...
@@ -272,26 +273,22 @@ static int browseSSHKeyInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev
...
@@ -272,26 +273,22 @@ static int browseSSHKeyInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev
}
}
}
}
/* delete keys from dmmap which are not available in KEY_FILE */
stmp
=
NULL
;
stmp
=
NULL
;
s
=
NULL
;
s
=
NULL
;
uci_path_foreach_sections_safe
(
bbfdm
,
"dmmap_sshmngr"
,
"authkey"
,
stmp
,
s
)
{
uci_path_foreach_sections_safe
(
bbfdm
,
"dmmap_sshmngr"
,
"authkey"
,
stmp
,
s
)
{
char
*
val
=
NULL
;
char
*
val
=
NULL
;
dmuci_get_value_by_section_string
(
s
,
"pubkey"
,
&
val
);
dmuci_get_value_by_section_string
(
s
,
"pubkey"
,
&
val
);
if
(
!
key_exist_in_keyfile
(
val
,
json_key_list
))
{
if
(
!
key_exist_in_keyfile
(
val
,
json_key_list
))
{
/* delete keys from dmmap which are not available in KEY_FILE */
dmuci_delete_by_section
(
s
,
NULL
,
NULL
);
dmuci_delete_by_section
(
s
,
NULL
,
NULL
);
}
}
else
{
}
data
.
dmmap_section
=
s
;
/* enlist objects */
/* enlist objects */
inst
=
handle_instance
(
dmctx
,
parent_node
,
s
,
"instance"
,
"alias"
);
stmp
=
NULL
;
s
=
NULL
;
uci_path_foreach_sections_safe
(
bbfdm
,
"dmmap_sshmngr"
,
"authkey"
,
stmp
,
s
)
{
if
(
DM_LINK_INST_OBJ
(
dmctx
,
parent_node
,
&
data
,
inst
)
==
DM_STOP
)
inst
=
handle_instance
(
dmctx
,
parent_node
,
s
,
"instance"
,
"alias"
);
break
;
}
if
(
DM_LINK_INST_OBJ
(
dmctx
,
parent_node
,
(
void
*
)
s
,
inst
)
==
DM_STOP
)
break
;
}
}
return
0
;
return
0
;
}
}
...
@@ -634,17 +631,17 @@ static int get_ssh_server_session_port(char *refparam, struct dmctx *ctx, void *
...
@@ -634,17 +631,17 @@ static int get_ssh_server_session_port(char *refparam, struct dmctx *ctx, void *
static
int
get_ssh_key_alias
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
**
value
)
static
int
get_ssh_key_alias
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
**
value
)
{
{
return
bbf_get_alias
(
ctx
,
(
struct
uci_section
*
)
data
,
"alias"
,
instance
,
value
);
return
bbf_get_alias
(
ctx
,
(
(
struct
dm_data
*
)
data
)
->
dmmap_section
,
"alias"
,
instance
,
value
);
}
}
static
int
set_ssh_key_alias
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
*
value
,
int
action
)
static
int
set_ssh_key_alias
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
*
value
,
int
action
)
{
{
return
bbf_set_alias
(
ctx
,
(
struct
uci_section
*
)
data
,
"alias"
,
instance
,
value
);
return
bbf_set_alias
(
ctx
,
(
(
struct
dm_data
*
)
data
)
->
dmmap_section
,
"alias"
,
instance
,
value
);
}
}
static
int
get_ssh_key_pubkey
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
**
value
)
static
int
get_ssh_key_pubkey
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
**
value
)
{
{
dmuci_get_value_by_section_string
((
struct
uci_section
*
)
data
,
"pubkey"
,
value
);
dmuci_get_value_by_section_string
((
(
struct
dm_data
*
)
data
)
->
dmmap_section
,
"pubkey"
,
value
);
return
0
;
return
0
;
}
}
...
@@ -658,7 +655,7 @@ static int set_ssh_key_pubkey(char *refparam, struct dmctx *ctx, void *data, cha
...
@@ -658,7 +655,7 @@ static int set_ssh_key_pubkey(char *refparam, struct dmctx *ctx, void *data, cha
return
FAULT_9007
;
return
FAULT_9007
;
/* check if same as current key value */
/* check if same as current key value */
dmuci_get_value_by_section_string
((
struct
uci_section
*
)
data
,
"pubkey"
,
&
cur_val
);
dmuci_get_value_by_section_string
((
(
struct
dm_data
*
)
data
)
->
dmmap_section
,
"pubkey"
,
&
cur_val
);
if
(
DM_STRCMP
(
cur_val
,
value
)
==
0
)
if
(
DM_STRCMP
(
cur_val
,
value
)
==
0
)
break
;
break
;
...
@@ -668,12 +665,12 @@ static int set_ssh_key_pubkey(char *refparam, struct dmctx *ctx, void *data, cha
...
@@ -668,12 +665,12 @@ static int set_ssh_key_pubkey(char *refparam, struct dmctx *ctx, void *data, cha
break
;
break
;
case
VALUESET
:
case
VALUESET
:
/* check if same as current key value then nothing to do */
/* check if same as current key value then nothing to do */
dmuci_get_value_by_section_string
((
struct
uci_section
*
)
data
,
"pubkey"
,
&
cur_val
);
dmuci_get_value_by_section_string
((
(
struct
dm_data
*
)
data
)
->
dmmap_section
,
"pubkey"
,
&
cur_val
);
if
(
DM_STRCMP
(
cur_val
,
value
)
==
0
)
if
(
DM_STRCMP
(
cur_val
,
value
)
==
0
)
break
;
break
;
add_pubkey
(
cur_val
,
value
);
add_pubkey
(
cur_val
,
value
);
dmuci_set_value_by_section
((
struct
uci_section
*
)
data
,
"pubkey"
,
value
);
dmuci_set_value_by_section
((
(
struct
dm_data
*
)
data
)
->
dmmap_section
,
"pubkey"
,
value
);
break
;
break
;
}
}
return
0
;
return
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment