Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upFix for chroot not getting supplemental groups #1398
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
coolacid
May 22, 2014
Contributor
I could "fix" logstash-web, but I see no reason why it should require the extra groups to run.
|
I could "fix" logstash-web, but I see no reason why it should require the extra groups to run. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
spuder
May 22, 2014
Before the patch logstash could not read files owned by root:adm with permissions of 640, after the patch, logstach can read those files.
Tested on ubuntu 12.04
spuder
commented
May 22, 2014
|
Before the patch logstash could not read files owned by root:adm with permissions of 640, after the patch, logstach can read those files. Tested on ubuntu 12.04 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
electrical
May 22, 2014
Contributor
Cool solution, im only afraid of the situation when there are no additional groups would the command fail then because its missing group names?
Perhaps an idea to do something like:
if CGROUPS is not empty then set EXTRA_GROUPS to '--groups $CGROUPS' and use the EXTRA_GROUPS in the command?
|
Cool solution, im only afraid of the situation when there are no additional groups would the command fail then because its missing group names? Perhaps an idea to do something like: |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
coolacid
May 22, 2014
Contributor
New commit tests to see if there was anything returned.
tested with my username - I get EXTRA_GROUPS, with another account it's blank as expected.
|
New commit tests to see if there was anything returned. tested with my username - I get EXTRA_GROUPS, with another account it's blank as expected. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
coolacid
May 22, 2014
Contributor
I was not aware of the command - and you're right, pam could be a problem too.
The command as provided gives group numbers, which would work - let me play some more.
|
I was not aware of the command - and you're right, pam could be a problem too. The command as provided gives group numbers, which would work - let me play some more. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
coolacid
May 22, 2014
Contributor
I don't remove the already set group anymore, but I can't see that hurting anything.
|
I don't remove the already set group anymore, but I can't see that hurting anything. |
jordansissel
reviewed
May 22, 2014
| @@ -50,11 +50,20 @@ start() { | ||
| JAVA_OPTS=${LS_JAVA_OPTS} | ||
| export PATH HOME JAVA_OPTS LS_HEAP_SIZE LS_JAVA_OPTS LS_USE_GC_LOGGING | ||
| # chown doesn't grab the suplimental groups when setting the user:group - so we have to do it for it. | ||
| # Boy, I hope we're root here. | ||
| SGROUPS=$(id -Gn "$LS_USER" | tr " " "," | sed 's/,$//'; echo '') |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jordansissel
May 22, 2014
Contributor
+1 using id instead of grep /etc/group seems like a good approach.
jordansissel
May 22, 2014
Contributor
+1 using id instead of grep /etc/group seems like a good approach.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
spuder
May 22, 2014
The updated pull request works great for me.
74dfd2b
chmod 640 /tmp/foo
/etc/init.d/logstash-coolacid3 start
logstash started.
echo "logstash-coolacid3 640" >> /tmp/foo
tail -n1 /tmp/bar
{"message":"logstash-coolacid3 640","@version":"1","@timestamp":"2014-05-22T20:48:15.742Z","host":"foosball.ac","path":"/tmp/foo"}
If the init script was generated by 'pleaserun', I wonder if there needs to be a bug-hancement filed on that project as well?
spuder
commented
May 22, 2014
|
The updated pull request works great for me.
If the init script was generated by 'pleaserun', I wonder if there needs to be a bug-hancement filed on that project as well? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
electrical
May 22, 2014
Contributor
@spuder all issues that we see here with with the init script we silently try to port over to pleaserun :-)
Feel free to open the issue there so we can solve it permanently.
|
@spuder all issues that we see here with with the init script we silently try to port over to pleaserun :-) |
spuder
referenced this pull request
May 22, 2014
Open
sysv init scripts only run with the primary group #50
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
spuder
Jun 3, 2014
Is there an expected release for this fix? I'd really like to see it make it into 1.4.2 since logstash is broken on all Ubuntu nodes at the moment.
spuder
commented
Jun 3, 2014
|
Is there an expected release for this fix? I'd really like to see it make it into 1.4.2 since logstash is broken on all Ubuntu nodes at the moment. |
z0rc
referenced this pull request
Jun 27, 2014
Closed
Permission denied reading files with adm group on Ubuntu 12.04 #1449
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
victorgp
Jul 10, 2014
How is possible that logstash is broken in, at least, all ubuntu nodes and this fix is not already merged?
victorgp
commented
Jul 10, 2014
|
How is possible that logstash is broken in, at least, all ubuntu nodes and this fix is not already merged? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
elasticsearch-release
commented
Jul 10, 2014
|
Can one of the admins verify this patch? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jordansissel
Jul 10, 2014
Contributor
@victorgp I am sorry that you are negatively impacted by this. From your comment, I can tell you are excited to see this patch merged!
While I believe this patch to work (testing by hand on one OS distro version), it would be greatly useful to us to know if it works for you. Further, this script is also used on CentOS/RHEL/SLES systems, can you help us test on those? I don't have access yet to all of those systems so it is difficult to do such testing in isolation. We are always working to improve our testing infrastructure as well to help cover these situations.
Any testing you can do on this would be lovely. As a bonus, by testing this, you would apply a workaround for your own infrastructure until we provide a release with this patch (or something like it that is known to work on all supported platforms).
I would hate to merge this patch only to have you or someone else find it in the next release having caused something else to break. This is why testing is so important to us.
This is an open source project and community, and we are stronger if we work together! Any energy you can provide is most appreciated, though obviously not required :)
|
@victorgp I am sorry that you are negatively impacted by this. From your comment, I can tell you are excited to see this patch merged! While I believe this patch to work (testing by hand on one OS distro version), it would be greatly useful to us to know if it works for you. Further, this script is also used on CentOS/RHEL/SLES systems, can you help us test on those? I don't have access yet to all of those systems so it is difficult to do such testing in isolation. We are always working to improve our testing infrastructure as well to help cover these situations. Any testing you can do on this would be lovely. As a bonus, by testing this, you would apply a workaround for your own infrastructure until we provide a release with this patch (or something like it that is known to work on all supported platforms). I would hate to merge this patch only to have you or someone else find it in the next release having caused something else to break. This is why testing is so important to us. This is an open source project and community, and we are stronger if we work together! Any energy you can provide is most appreciated, though obviously not required :) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
victorgp
Jul 10, 2014
@jordansissel sorry for the negativity, i didn't want to seem so negative. I will try to help you testing the patch in Debian and Ubuntu, i don't have access to other distros either. Let's see if i can find some free time one of these days to test it.
victorgp
commented
Jul 10, 2014
|
@jordansissel sorry for the negativity, i didn't want to seem so negative. I will try to help you testing the patch in Debian and Ubuntu, i don't have access to other distros either. Let's see if i can find some free time one of these days to test it. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
victorgp
Jul 15, 2014
The tests i've done tell me that this fix is not fully complete. It does work for old scripts located in /etc/init.d/ but it is still broken for upstart scripts in /etc/init/
I suppose the file logstash.upstart.ubuntu must be fixed, but it is no using chroot to run the program, why? i guess both should run in the same way...
BTW anyone knows what is the version that introduced this bug?
victorgp
commented
Jul 15, 2014
|
The tests i've done tell me that this fix is not fully complete. It does work for old scripts located in /etc/init.d/ but it is still broken for upstart scripts in /etc/init/ I suppose the file logstash.upstart.ubuntu must be fixed, but it is no using chroot to run the program, why? i guess both should run in the same way... BTW anyone knows what is the version that introduced this bug? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
electrical
Jul 15, 2014
Contributor
Hi,
The upstart script didn't get the love yet it deserves but we will soon do that.
|
Hi, The upstart script didn't get the love yet it deserves but we will soon do that. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
spuder
Jul 15, 2014
I find it very interesting that other people are still able to use logstash despite this bug. It is an absolute blocker for me. I'm trying to setup the simplest possible logstash cluster as shown in the examples in the logstash book, but can't work around this without significant chmod hackery.
Surely every one who tries to use logstash is running into this bug, no?
Maybe every other sysadmin is just doing a chmod 777 on all their logs.
If anyone has thoughts on why more people aren't blocked by this, I'd love to hear it.
spuder
commented
Jul 15, 2014
|
I find it very interesting that other people are still able to use logstash despite this bug. It is an absolute blocker for me. I'm trying to setup the simplest possible logstash cluster as shown in the examples in the logstash book, but can't work around this without significant chmod hackery. Surely every one who tries to use logstash is running into this bug, no? |
colinsurprenant
added
bug
labels
Jul 18, 2014
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
coolacid
Jul 18, 2014
Contributor
As far as I can see upstart doesn't use chown -- and IIRC when I did these patches, I looked though all the startup scripts to see if they would have the same problem.
|
As far as I can see upstart doesn't use chown -- and IIRC when I did these patches, I looked though all the startup scripts to see if they would have the same problem. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
heytchap
Jul 23, 2014
Hey guys. Not sure if it's just me but the @coolacid modifications posted above still prevent me from reading anything root:adm with 640 permissions. Have modified both sysv and upstart but issue remains. Am I the only one?
heytchap
commented
Jul 23, 2014
|
Hey guys. Not sure if it's just me but the @coolacid modifications posted above still prevent me from reading anything root:adm with 640 permissions. Have modified both sysv and upstart but issue remains. Am I the only one? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
@heytchap Did you add logstash to the adm group? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
heytchap
Jul 23, 2014
@coolacid I did. I also added the LS user to root and syslog.
to confirm, the following command gives me this output:
id logstash
uid=999(logstash) gid=999(logstash) groups=999(logstash),0(root),4(adm),104(syslog)
so Im not sure what the hangup is here.
heytchap
commented
Jul 23, 2014
|
@coolacid I did. I also added the LS user to root and syslog. id logstash so Im not sure what the hangup is here. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lasse-aagren
Aug 27, 2014
setfacl is easy and works fine with logstash for these kind of files on Debian GNU/Linux (where I have tested it). It is just an abstraction layer that I would like to do without. Probably mostly out of old habit :) And it is easy to distribute with configuration management like puppet or similar, so if setfacl is the solution, I'll accept it :)
lasse-aagren
commented
Aug 27, 2014
|
setfacl is easy and works fine with logstash for these kind of files on Debian GNU/Linux (where I have tested it). It is just an abstraction layer that I would like to do without. Probably mostly out of old habit :) And it is easy to distribute with configuration management like puppet or similar, so if setfacl is the solution, I'll accept it :) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jordansissel
Aug 27, 2014
Contributor
@lasse-aagren Indeed! My hope, for now, is that setfacl is simply a workaround until we can fix it. This assumes all process-launcher systems are capable of setting supplementary groups- Supervisord, for example, appears only to support setting user, not even group, nor supplementary groups.
|
@lasse-aagren Indeed! My hope, for now, is that setfacl is simply a workaround until we can fix it. This assumes all process-launcher systems are capable of setting supplementary groups- Supervisord, for example, appears only to support setting user, not even group, nor supplementary groups. |
jordansissel
added
the
O(0)
label
Sep 22, 2014
jordansissel
added
the
O(0)
label
Nov 11, 2014
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jacek-berlin
Nov 28, 2014
Hi,
I've just stumbled upon this bug (Logstash 1.4.2, Debian Wheezy) .
Quick and dirty fix (if you trust your system) would be also to comment out the chroot line.
#### Works fine
# Run the program!
# nice -n ${LS_NICE} chroot --userspec $LS_USER:$LS_GROUP /
sh -c "
cd $LS_HOME
ulimit -n ${LS_OPEN_FILES}
exec \"$program\" $args
" > "${LS_LOG_DIR}/$name.stdout" 2> "${LS_LOG_DIR}/$name.err" &
jacek-berlin
commented
Nov 28, 2014
|
Hi, Quick and dirty fix (if you trust your system) would be also to comment out the chroot line.
|
electrical
referenced this pull request
Feb 3, 2015
Closed
Logstash having trouble accessing a file it has permissions to access #2281
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
sdklein
Feb 12, 2015
+1 for the solution. I tested this pull request on CentOS 7 and it worked as expected.
sdklein
commented
Feb 12, 2015
|
+1 for the solution. I tested this pull request on CentOS 7 and it worked as expected. |
jordansissel
added
the
O(0)
label
Feb 25, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
franklinwise
commented
Apr 28, 2015
|
When is this getting merged? |
suyograo
removed
the
confirmed
label
May 15, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jhoff909
Jun 9, 2015
Curious when this is going to get merged? Like others, I can't imagine that most folks using logstash to read files aren't running into this and spending a lot of time either figuring it out or reading posts like the above...
jhoff909
commented
Jun 9, 2015
|
Curious when this is going to get merged? Like others, I can't imagine that most folks using logstash to read files aren't running into this and spending a lot of time either figuring it out or reading posts like the above... |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
vasti
Jun 16, 2015
Variable HOME is exported without setting value to it. There's HOME=${LS_HOME} on master.
I get error No SINCEDB_DIR or HOME environment variable set, I don't know where to keep track of the files I'm watching. Either set HOME or SINCEDB_DIR in your environment, or set sincedb_path in in your Logstash config for the file input with path because of that.
vasti
commented
Jun 16, 2015
|
Variable |
jordansissel
removed
the
O(0)
label
Jun 29, 2015
jordansissel
added
v1.5.3
and removed
v1.5.2
labels
Jul 6, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jordansissel
Jul 6, 2015
Contributor
I think we've had enough folks report that this patch works for them that I am ok to merge it.
|
I think we've had enough folks report that this patch works for them that I am ok to merge it. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
elasticsearch-bot
commented
Jul 6, 2015
|
Merged sucessfully into master 1.5! |
coolacid commentedMay 22, 2014
linux chroot doesn't get the supplemental groups before dropping privileges. As such, we need to pull it from /etc/group and tweak it so that we can send them to chroot.
Original report came from @spuder on irc -- here is his GIST report:
https://gist.github.com/spuder/a1c3c7d10ce129507858
Spuder tested this and reported it working. Should work on other systems that use sysv init.