SUMMARY (not quite) Illegal instruction in cp

From: Oscar Goldes (ogolde@impsat1.com.ar)
Date: Mon Apr 14 1997 - 09:23:57 CDT


Original question
> I have a setuid-root C program that needs to copy /etc/passwd and
> /etc/shadow to make some changes and write them back. To do this, it makes a
> system("cp /etc/passwd /tmp/xxx"). This frequently leads to a core dump,
> caused by an "illegal instruction", signal 4.
> Running the program under truss, it fails ALWAYS. Running the program alone,
> it fails frequently (but not always).

Thanks to all who replied (a lot of people, really!)

I got a lot of replies telling me that I should never do what I tried to do.
OK, I know it is dangerous.

I just changed the program to use normal C library calls to do the copying
instead of using system(cp......) and all works well now.

I did no further research about why it did not work the other way.

Regards



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:50 CDT