Skip to content

Commit

Permalink
cmd/snap-confine: move definition of invocation earlier
Browse files Browse the repository at this point in the history
This will allow us to remove the locals that are duplicated in main.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
  • Loading branch information
zyga committed Mar 11, 2019
1 parent efaa93c commit 0a961c1
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions cmd/snap-confine/snap-confine.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ int main(int argc, char **argv)

sc_snap_name_validate(base_snap_name, NULL);


/* Invocation helps to pass relevant data to various parts of snap-confine. */
sc_invocation invocation = {
.base_snap_name = base_snap_name,
.executable = executable,
.security_tag = security_tag,
.snap_instance = snap_instance,
.classic_confinement = classic_confinement
/* is_normal_mode is not probed yet */
};

debug("security tag: %s", security_tag);
debug("executable: %s", executable);
debug("confinement: %s",
Expand Down Expand Up @@ -190,16 +201,6 @@ int main(int argc, char **argv)
" but should be. Refusing to continue to avoid"
" permission escalation attacks");
}

/* Invocation helps to pass relevant data to various parts of snap-confine. */
sc_invocation invocation = {
.base_snap_name = base_snap_name,
.executable = executable,
.security_tag = security_tag,
.snap_instance = snap_instance,
.classic_confinement = classic_confinement
/* is_normal_mode is not probed yet */
};
// TODO: check for similar situation and linux capabilities.
if (geteuid() == 0) {
if (classic_confinement) {
Expand Down

0 comments on commit 0a961c1

Please sign in to comment.