Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: share internal API symbols #2437

Merged
merged 37 commits into from
Jul 1, 2018
Merged

tools: share internal API symbols #2437

merged 37 commits into from
Jul 1, 2018

Conversation

2xsec
Copy link
Contributor

@2xsec 2xsec commented Jun 28, 2018

Hello,

I'm working to share internal API symbols to tools.

I'll add commit for other tools to this pull request.

Before that, if you have any opinion for that, Please let us know.

Thanks.

Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
@lxc-jenkins
Copy link

This pull request didn't trigger Jenkins as its author isn't in the whitelist.

An organization member must perform one of the following:

  • To have this branch tested by Jenkins, use the "ok to test" command.
  • To have a one time test done, use the "test this please" command.

Those commands are simple Github comments of the format: "jenkins: COMMAND"

@brauner
Copy link
Member

brauner commented Jun 28, 2018

jenkins: test this please

1 similar comment
@brauner
Copy link
Member

brauner commented Jun 28, 2018

jenkins: test this please

@brauner
Copy link
Member

brauner commented Jun 29, 2018

@2xsec, just ping me when you think this branch is ready to be merged. :)

@2xsec
Copy link
Contributor Author

2xsec commented Jun 29, 2018

OK^^

@brauner
Copy link
Member

brauner commented Jun 29, 2018

Note, that we should keep symbols that are only used by the tools restricted to the tools, i.e. they should not appear in the dependency list or files for the shared library itself. :)

@brauner
Copy link
Member

brauner commented Jun 29, 2018

Also, in case you're at OSS NA or OSS EU, or Linux Plumbers you've earned a drink. :)

@2xsec
Copy link
Contributor Author

2xsec commented Jun 29, 2018

Dear Mr.Brauner,

All works are finished. Some tools have still issues related logs. But I think it is not critical issue.

I'll fix them later. And some apis are still duplicated like lxc_tool_monitord_spawn, lxc_tool_check_inherited in lxc_monitor.c.

Please let us know your opinion.

Thanks^^

@brauner
Copy link
Member

brauner commented Jun 29, 2018

Please, no Mr. necessary I'm far away from that. :)
Cool, I'll give this a look tomorrow and if all checks out I'll merge.

@brauner
Copy link
Member

brauner commented Jun 29, 2018

Hm, lxc-test-autostart seems unhappy. :)

@2xsec
Copy link
Contributor Author

2xsec commented Jun 30, 2018

I'll check it.

@brauner
Copy link
Member

brauner commented Jun 30, 2018

@2xsec, can you merge the last commit into the other lxc-autostart commit, please?

@2xsec
Copy link
Contributor Author

2xsec commented Jun 30, 2018

@brauner, I didn't understand. How do I for that?

@brauner
Copy link
Member

brauner commented Jun 30, 2018

@2xsec, asciicast
:)

Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
@2xsec
Copy link
Contributor Author

2xsec commented Jun 30, 2018

@brauner It's done. But, push is failed.

guybrush@nt900x5t:~/Project/github/lxc$ git push origin bugfix
Username for 'https://github.com': 2xsec
Password for 'https://2xsec@github.com':
To https://github.com/2xsec/lxc.git
! [rejected] bugfix -> bugfix (non-fast-forward)
error: failed to push some refs to 'https://github.com/2xsec/lxc.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

@brauner
Copy link
Member

brauner commented Jun 30, 2018

@2xsec use git push --force in such cases. :)

@2xsec
Copy link
Contributor Author

2xsec commented Jun 30, 2018

@brauner Thanks^^

@2xsec
Copy link
Contributor Author

2xsec commented Jun 30, 2018

apparmor-mount TC is failed. I'll check it again.

FAIL: lxc-tests: /usr/bin/lxc-test-apparmor-mount

@brauner
Copy link
Member

brauner commented Jun 30, 2018

No, you can ignore that error. It's caused by:

Setting up the GPG keyring
ERROR: Unable to fetch GPG key from keyserver

@2xsec
Copy link
Contributor Author

2xsec commented Jun 30, 2018

@brauner ok.

Copy link
Member

@brauner brauner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically just nits and questions. Otherwise lgtm. Once those things are addressed I'll merge.

if (! p1 && ! str_ptr)
return 1;
if (! p1 && ! *str_ptr)
if (!p1 && !str_ptr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're trying to replace the logic exactly shouldn't this be:

if (!p1 && !str_ptr || !p1 && !*str_ptr)

or

if (!p1 && (!str_ptr || !*str_ptr))

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right. I fixed it.

if (strcmp(it1->elem, it2->elem) == 0)
return 1;
}
if (!strncmp(it1->elem, str_ptr, strlen(it1->elem)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use strncmp() == 0 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it.

@@ -372,7 +361,7 @@ int main(int argc, char *argv[])
qsort(&containers[0], count, sizeof(struct lxc_container *), cmporder);

if (cmd_groups_list && my_args.all)
fprintf(stderr, "Specifying -a (all) with -g (groups) doesn't make sense. All option overrides.\n");
ERROR("Specifying -a (all) with -g (groups) doesn't make sense. All option overrides.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the trailing . while you're at it. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it.

@@ -404,27 +393,28 @@ int main(int argc, char *argv[])
/* We're done with this container */
if ( lxc_container_put(c) > 0 )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove the unnecessary spaces here as well. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it.

@@ -60,21 +61,25 @@ int main(int argc, char *argv[])
struct lxc_config_items *i;
const char *value;

if (argc < 2 || strcmp(argv[1], "-h") == 0 ||
strcmp(argv[1], "--help") == 0)
if (argc < 2 || !strncmp(argv[1], "-h", strlen(argv[1])) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

== 0 syntax, please. It's in our coding style. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it.

if (strncmp(a->bdevtype, "lvm", strlen(a->bdevtype)) &&
strncmp(a->bdevtype, "loop", strlen(a->bdevtype)) &&
strncmp(a->bdevtype, "rbd", strlen(a->bdevtype))) {
ERROR("Filesystem type and size are only valid with block devices");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!= 0 syntax, please :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it.

if (!my_args.bdevtype)
my_args.bdevtype = "_unset";

if (!validate_bdev_args(&my_args))
exit(EXIT_FAILURE);

if (strcmp(my_args.bdevtype, "none") == 0)
if (!strncmp(my_args.bdevtype, "none", strlen(my_args.bdevtype)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm note sure those are necessary, strcmp() should be sufficient and safe and spares us a strlen() call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using strncmp instead of strcmp to prevent bof attack habitually. But input validation and checking length for input are valid, there is no problem. In case of this, it is sufficient and safe. You are right.

if (p < 0) {
fprintf(stderr, "failed to fork task.\n");
ERROR("Failed to fork task.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, can you remove the trailing . as well :)

@@ -1290,3 +1323,51 @@ static void ls_field_width(const struct ls *l, const size_t size,
}
}
}

static int rm_r(char *dirname)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, you could also move static int recursive_destroy(char *dirname) from cgroups/cgfsng.c to utils.{c,h} and call it rm_r() and use it in both places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check it you mentioned after tools are merged.

@@ -218,13 +221,13 @@ static int do_snapshot_destroy(struct lxc_container *c, char *snapname)
{
bool ret;

if (strcmp(snapname, "ALL") == 0)
if (!strncmp(snapname, "ALL", strlen(snapname)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

== 0 syntax, please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it.

2xsec added 11 commits July 1, 2018 22:37
…ncmp

Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
@brauner
Copy link
Member

brauner commented Jul 1, 2018

jenkins: test this please

@brauner brauner merged commit 2d876a9 into lxc:master Jul 1, 2018
@brauner
Copy link
Member

brauner commented Jul 1, 2018

Thanks! :)

@2xsec
Copy link
Contributor Author

2xsec commented Jul 2, 2018

Thanks for your review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants