LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-01-2013, 10:48 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
Cannot open ./setuid_06


Hi:

Code:
root@local:/home/semoi/z80_2013/emulate_uart# ls -l setuid_06
-rwsr-sr-x 1 root root 9181 2013-06-01 22:51 setuid_06*
root@local:/home/semoi/z80_2013/emulate_uart# file ./setuid_06
./setuid_06: setuid setgid ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
root@local:/home/semoi/z80_2013/emulate_uart# whoami
root
root@local:/home/semoi/z80_2013/emulate_uart# ./setuid_06
Cannot open ./setuid_06
root@local:/home/semoi/z80_2013/emulate_uart#
I cannot understand why the system refuses to run this program. It did until yesterday. No longer now and I am using a security copy of the program. Besides, who is saying 'Cannot open ./setuid_06'? What can the system possible find wrong with the program?

NOTE: why I had to set the "set user or group ID on execution" bit I do not remember.

Last edited by stf92; 06-01-2013 at 10:57 PM.
 
Old 06-01-2013, 11:47 PM   #2
elvis4526
Member
 
Registered: Aug 2011
Posts: 114

Rep: Reputation: Disabled
1) What is this program exactly?
2) Are you on Slackware 64 bits ?
 
Old 06-01-2013, 11:58 PM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Quote:
Originally Posted by elvis4526 View Post
1) What is this program exactly?
2) Are you on Slackware 64 bits ?
It outputs data through the machine's parallel port. Yes, this is Slackware 14.0 x86_64.
 
Old 06-02-2013, 12:45 AM   #4
elvis4526
Member
 
Registered: Aug 2011
Posts: 114

Rep: Reputation: Disabled
Okay.
Since it's a 32 bits binary, did you install all the multilib packages provided by AlienBob ?
 
Old 06-02-2013, 01:00 AM   #5
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
No, I didn't. But I forgot something. I have the program source file. Now I'm trying to compile it in this, which is a 64-bit machine. Unfortunately, I get:
Code:
semoi@server:~/z80_p4/juan$ gcc -O2 -o p1 p1.c
p1.c:26:42: fatal error: asm/io.h: No such file or directory
compilation terminated.
The source has this line:
Code:
   #include <asm/io.h>        // for outb
locate asm/io.h finds hundreds of instances. I do not understand. In what directory should asm/io.h should be?
 
Old 06-02-2013, 01:29 AM   #6
elvis4526
Member
 
Registered: Aug 2011
Posts: 114

Rep: Reputation: Disabled
Well yeah, if you try to run a 32 bits binary on a 64 bits system without any kind of multilib packages installed, this won't work for sure.
I don't think compiling it by hand without any kind of makefile or even some instructions from the maintainer of this program is a good idea.

I would suggest to install the multilib packages provided by alienBOB and then try again to launch the compiled binary to see how it goes.
 
Old 06-02-2013, 01:56 AM   #7
wildwizard
Member
 
Registered: Apr 2009
Location: Oz
Distribution: slackware64-14.0
Posts: 875

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally Posted by stf92 View Post
The source has this line:
Code:
   #include <asm/io.h>        // for outb
locate asm/io.h finds hundreds of instances. I do not understand. In what directory should asm/io.h should be?
man outb gives <sys/io.h>

The code is old and needs to be updated for current kernel header layouts.
 
Old 06-02-2013, 02:07 AM   #8
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
But it is I who wrote the program and I have run it without problems many times already. Forget about the compilation on the 64-bit machine (gcc will produce 64 bit code). I was wrong. Do as if I were running a 32-bit machine. The program must do I/O. So it must do a setuid. For that, the owner must be root, otherwise the system won't let the program to do the setuid. As I learned in the internet, I must set the "set user or group ID on execution" bit of the file. So the file is left with these permissions:

-rwsr-sr-x

I always did this and the things went well. Now, when trying to run it, I get the 'Cannot open <file name>' message. If I remove the "s" bit, however, I can run it. But then the system does not let the program do the setuid. I must have touched something in the system. I have to recollect. Or perhaps I'm obviating some step now. But the source is exactly the same as when everything went well.
 
Old 06-02-2013, 02:13 AM   #9
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Quote:
Originally Posted by wildwizard View Post
man outb gives <sys/io.h>

The code is old and needs to be updated for current kernel header layouts.
Thank you very much. I was making a mistake. The program must be compiled in the 32-bit machine where it is to be run. That is, ggc must compile for 32 bits. To make it easy, I compile in the 32-bit machine remotely from a 64-bit machine (more comfortable place to work in). So no problems with the compilation now.

What I can't do is make run. I explained these things in the post above this. Again thanks, wildwizard.





NOTE: simply stated: with this permissions mask,

-rwsr-sr-x 1 semoi semoi 9181 2006-03-13 05:58 setuid_06

running the program the system will say 'Cannot open setuid_06'. With this one, the system will run it:

-rwxr-xr-x 1 semoi semoi 9181 2006-03-13 05:58 setuid_06

but then the program won't be able to operate correctly. The precise implications of using the "s" bit I do not know them.

Last edited by stf92; 06-02-2013 at 02:23 AM.
 
Old 06-02-2013, 04:20 AM   #10
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
The fault was the user's and not the program's. This is a part of the source:
Code:
int main(int argc, char** argv){
        int     i;
        
        if (permisos()) {
                printf("Error getting permissions.\n");
                return 0;
        }
        
        infile = fopen(argv[1], "rb");
        if(!infile){
                fprintf(stderr, "Cannot open %s\n", argv[0]);
                return 0;
        }
        
        // fileno gets the file descriptor out of stream infile
        fstat(fileno(infile), &buf);
        filesize= buf.st_size - 10;     // get the file size
        printf("File size is %d decimal.\n", filesize);

        image= msk_data | msk_clock;
        outb(image, port);
        printf("Press a key to begin transmition."); getchar();
After trying to open the file
Code:
        infile = fopen(argv[1], "rb");
        if(!infile){
                fprintf(stderr, "Cannot open %s\n", argv[0]);
                return 0;
        }
the program checks for errors. In case it finds one, it prints the infamous message "Cannot open <argv[0]>". Here, a second error, because it should be argv[1], the filename that the user must type after the program name. I systematically forgot to specify a filename in the command line. Because I mistakenly wrote argv[0], the resulting message was 'Cannot open ./setuid_06', the name of the program. However the program should warn there is no argument. I had quite forgotten how to use it. That was my great question. Generally system and utilities messages are preceded by the name of the one who talks. This was preceded by nothing! For the record, I made this circumstance explicit in the thread.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
xdg-open, gnome-open or kde(4?)-open??? akamikeym Programming 0 08-03-2010 08:54 AM
LXer: SaaS Partners Boost Open-Xchange Open Source Email LXer Syndicated Linux News 0 12-17-2009 07:00 AM
LXer: Linux Foundation plans new, more open open-source conference next year LXer Syndicated Linux News 0 09-30-2008 11:40 AM
LXer: Open Country Upgrades Webmin Open Source IT System Administration ... LXer Syndicated Linux News 0 11-25-2006 06:21 PM
LXer: Open BI Forum: Live ... From the World Technology Community ... It's Open Source BI! LXer Syndicated Linux News 0 07-27-2006 10:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 04:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration