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

Use Cgo instead of compiling external helper #57

Closed
pquerna opened this issue Jul 24, 2015 · 5 comments
Closed

Use Cgo instead of compiling external helper #57

pquerna opened this issue Jul 24, 2015 · 5 comments

Comments

@pquerna
Copy link
Contributor

pquerna commented Jul 24, 2015

1284363

As a consumer of gopsutils, putting in a hard coded path to compile a C file at runtime is not an acceptable behavior. Is there any reason to not just use Cgo to call these functions?

@pquerna
Copy link
Contributor Author

pquerna commented Jul 24, 2015

reasons the current /tmp C file solution isn't ok:

  • It is a security vulnerability. Writing to a known path in /tmp can allow other users to write arbitrary files: https://en.wikipedia.org/wiki/Symlink_race
  • gcc is not available on all darwin hosts: gcc is part of the Developer Tools, which means many end users do not actually have it installed.

@pquerna
Copy link
Contributor Author

pquerna commented Jul 24, 2015

Example Cgo code for getting the data:
https://github.com/cloudfoundry/gosigar/blob/master/sigar_darwin.go#L112

(via @dougm)

@shirou
Copy link
Owner

shirou commented Jul 25, 2015

Is there any reason to not just use Cgo to call these functions

If I use Cgo, cross compiling becomes hard.

gcc is not available on all darwin hosts

Yes. but I think better than nothing.

It is a security vulnerability

Agree. I was wrong. Thank you.
I changed it only enabled if ALLLOW_INSECURE_CPU_HELPER is "yes" at c195d77.

I will start looking for another way to get CPU times.

@sparrc
Copy link
Contributor

sparrc commented Aug 27, 2015

+1 to this, I understand that it makes it hard to cross-compile, but I'd strongly prefer CGO over executing a binary compiled at runtime

@shirou
Copy link
Owner

shirou commented Aug 28, 2015

Now, I have changed my mind.
Since 47f6760, start to use CGO for darwin.
I close this issue. Please move to #66.

Thank you.

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

No branches or pull requests

3 participants