iconv_open fails when suid bit is on

iconv_open fails when suid bit is on

Yedidyah Bar-David linux-il at didi.bardavid.org
Mon Feb 13 12:22:00 IST 2012


On Mon, Feb 13, 2012 at 11:45:26AM +0200, guy keren wrote:
> 
> running "strace" on an suid binary - ignores the 'suid' bit. so the
> test with strace is not relevant.

Indeed, and to strace programs that do this, I do something like that:
Open a root shell:
# echo $$
let's say it printed 1234, so its pid is 1234


Open another root shell:
# strace -f -o /tmp/trace1 -p 1234

Now, inside 1234 run what you need to debug.
'strace -f -p pid' does follow correctly the uid changes caused by
suid binaries and setuid etc.

Some years ago I played a bit with the more obvious
# strace -f su - user -c program
which then did not work well. Not sure if this was changed. '-f -p pid'
always worked for me.

Sorry I can't comment about the actual OP quesion, but just a guess -
perhaps it's on nfs?
-- 
Didi

> On 02/13/2012 10:56 AM, Elazar Leibovich wrote:
> >In RHEL 5 system, libc-6, I'm seeing the following strange phenomena
> >
> >$ cat iconv_test.c
> >#include <stdio.h>
> >#include <errno.h>
> >#include <fcntl.h>
> >#include <iconv.h>
> >
> >void iconv_test() {
> >   static int nr = 0;
> >   iconv_t iconv = iconv_open("MSCP949","UTF-8");
> >   //iconv_t iconv = iconv_open("UTF-16","UTF-8");
> >   if (iconv == (iconv_t)-1) {
> >     puts( "can't initialize iconv");
> >   } else {
> >     puts( "iconv open success!" );
> >   }
> >   nr++;
> >}
> >
> >int main(int argc,char **argv) {
> >   iconv_test();
> >   return 0;
> >}
> >
> >$ gcc iconv_test.c
> >$ ./a.out
> >iconv open success!
> >$ sudo su -
> ># chown root:foo a.out
> ># chmod 4555 a.out
> ># su foo -
> >$ ./a.out
> >can't initialize iconv
> >$ strace ./a.out 2>/dev/null
> >iconv open success!
> >
> >
> >iconv_open on UTF-16 to UTF-8 succeeds!
> >This phenomena doesn't happen in recent Ubuntu.
> >
> >I'm not familiar with the inner workings of iconv, but stracing a good
> >iconv run reveals it dlopen so files according to the chosen encodings,
> >maybe it's related.
> >
> >1) I'll be glad for any thoughts or ideas how to debug this issue, other
> >than downloading the libc source rpm, compiling it, LD_PRELOAD, and hope
> >the problem will be recreated.
> >
> >2) If someone can test this on a RHEL-5 machine, and report if it
> >happens to him too, it could be helpful.
> >
> >Thanks,
> >
> >
> >_______________________________________________
> >Linux-il mailing list
> >Linux-il at cs.huji.ac.il
> >http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
> 
> 
> _______________________________________________
> Linux-il mailing list
> Linux-il at cs.huji.ac.il
> http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il



More information about the Linux-il mailing list