|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Ok, time to switch povray for a hello_world program then.
> (i.e. write & compile a hello_world program, and get it called from
> shell then php/webserver.
> 1. Does it work the same ? (does it fail the same way ?)
> 2. second level debugging: add more printf in the the hello program to
> display:
> * all the arguments/parameter (including argv[0]),
> * process id ( getpid() )
> * user id (both real & effective : getuid(), geteuid() )
> * current directory ( getcwd() or get_current_dir_name() )
> * perform some i/o operation on the disk (like opendir("/tmp"), and
> display all entries ? compare with actual content of /tmp)
>
> Something like that:
> -----------------------
>
> #include <sys/types.h>
> #include <dirent.h>
>
> int main(int argc,char**argv)
> {
> int ii;
> DIR* tmpdir;
> struct dirent *entry;
> printf("Hello, world\n");
> for(ii=0;ii<argc;ii++)
> {
> printf("arg %d : \"%s\"\n",ii,argv[ii]);
> }
> printf("This is pid %d\n",getpid());
> printf("Run as user %d (effective %d)\n",getuid(),geteuid());
> printf("The current directory is : %s\n",get_current_dir_name());
> tmpdir=opendir("/tmp");
> printf("Opendir /tmp returned: %p\n",tmpdir);
> if (tmpdir)
> {
> do
> {
> entry = readdir(tmpdir);
> if (entry)
> {
> printf("Filename %s\n",entry->d_name);
> }
> } while (entry);
> ii=closedir(tmpdir);
> printf("Closedir returned %d\n",ii);
> }
> return 0;
> }
>
> ----------------
I copied the above code into another file. Here's my output from the shell:
[jlb41@wyrd public_html]$ ./a.out
Hello, world
arg 0 : "./a.out"
This is pid 10972
Run as user 1547 (effective 1547)
The current directory is : /home/jlb41/public_html
Opendir /tmp returned: 0xb45030
Filename pulse-fIaYVQ4ftTFx
Filename pulse-ddsuEvxoRlP9
Filename .X0-lock
Filename orbit-gdm
Filename .ICE-unix
Filename .X11-unix
Filename 4d24887f11a5c
Filename lost+found
Filename orbit-acrum
Filename virtual-acrum.0BJ3Jx
Filename .esd-501
Filename ..
Filename pulse-OmdOnASl52ii
Filename .
Filename .htaccess
Filename pear
Filename virtual-acrum.ZeaNM4
Closedir returned 0
And the output from PHP:
Hello, world
arg 0 : "./a.out"
This is pid 10971
Run as user 48 (effective 48)
The current directory is : /home/jlb41/public_html
Opendir /tmp returned: 0x1601030
Filename pulse-fIaYVQ4ftTFx
Filename pulse-ddsuEvxoRlP9
Filename .X0-lock
Filename orbit-gdm
Filename .ICE-unix
Filename .X11-unix
Filename 4d24887f11a5c
Filename lost+found
Filename orbit-acrum
Filename virtual-acrum.0BJ3Jx
Filename .esd-501
Filename ..
Filename pulse-OmdOnASl52ii
Filename .
Filename .htaccess
Filename pear
Filename virtual-acrum.ZeaNM4
Closedir returned 0
When I run the code from both the shell and PHP, the /tmp value changes and the
pid increments. Is that supposed to happen?
I forgot to mention too that I can run shell commands like ls and dir from PHP.
Just not POV-Ray. I think it might have to do with some sort of permission
denial by PHP that I'm not knowing about.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Le 12/03/2011 20:18, Jess nous fit lire :
> This is pid 10972
> Run as user 1547 (effective 1547)
> The current directory is : /home/jlb41/public_html
> And the output from PHP:
> Hello, world
> arg 0 : "./a.out"
> This is pid 10971
> Run as user 48 (effective 48)
> The current directory is : /home/jlb41/public_html
> When I run the code from both the shell and PHP, the /tmp value changes and the
> pid increments. Is that supposed to happen?
>
Yes, it's a memory pointer... only Null would have been an issue.
> I forgot to mention too that I can run shell commands like ls and dir from PHP.
> Just not POV-Ray. I think it might have to do with some sort of permission
> denial by PHP that I'm not knowing about.
Time to check the rights of user 48, including its groups. (and the
compatibility with the installation of povray)
Can you "su - to_the_name_of_user_48" ?
(have a look/grep in /etc/passwd for 48)
And sanity check first: can 48 write in the current directory ?
Can php/web create a file ?
system("date >new_test_file")
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Time to check the rights of user 48, including its groups. (and the
> compatibility with the installation of povray)
> Can you "su - to_the_name_of_user_48" ?
> (have a look/grep in /etc/passwd for 48)
Here's the output when I grep-ed for 48. User 48 appears to be in Apache.
[jlb41@wyrd ~]$ grep 48 /etc/passwd
apache:x:48:48:Apache:/usr/local/apache2:/bin/bash
smolt:x:493:488:Smolt:/usr/share/smolt:/sbin/nologin
torrent:x:492:487:BitTorrent Seed/Tracker:/var/lib/bittorrent:/sbin/nologin
pulse:x:491:486:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
clamupdate:x:490:482:Clamav database update user:/var/lib/clamav:/sbin/nologin
clamilt:x:489:481:Clamav Milter User:/var/run/clamav-milter:/sbin/nologin
gam7:x:1486:1486:Gabriel Manzano:/home/gam7:/bin/bash
math470:x:1607:1607:Math 480 senior seminar:/home/math470:/bin/bash
webeffect:x:2148:2148::/home/webeffect:/bin/bash
skb1:x:1648:1648:Sharon Kay Beck:/home/skb1:/bin/bash
> And sanity check first: can 48 write in the current directory ?
> Can php/web create a file ?
> system("date >new_test_file")
PHP couldn't create the date file, so I guess that means User 48/PHP doesn't
have permission to create files.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Le 13/03/2011 07:57, Jess nous fit lire :
>
>> Time to check the rights of user 48, including its groups. (and the
>> compatibility with the installation of povray)
>> Can you "su - to_the_name_of_user_48" ?
>> (have a look/grep in /etc/passwd for 48)
>
> Here's the output when I grep-ed for 48. User 48 appears to be in Apache.
>
> [jlb41@wyrd ~]$ grep 48 /etc/passwd
> apache:x:48:48:Apache:/usr/local/apache2:/bin/bash
>> And sanity check first: can 48 write in the current directory ?
>> Can php/web create a file ?
>> system("date >new_test_file")
>
> PHP couldn't create the date file, so I guess that means User 48/PHP doesn't
> have permission to create files.
It's a matter of rights. I guess that jlb41 & apache are not in the same
primary group either, so the directory /home/jlb41/public_html would
need to be writable by other (and that might become a security/deface
issue; you might want to play in a deeper sub-directory in production).
First take note of the rights from "ls -ld /home/jlb41/public_html"
then try "chmod 777 /home/jlb41/public_html"
and try again php for system("date >new_test_file")
If it works, then try povray.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> It's a matter of rights. I guess that jlb41 & apache are not in the same
> primary group either, so the directory /home/jlb41/public_html would
> need to be writable by other (and that might become a security/deface
> issue; you might want to play in a deeper sub-directory in production).
>
> First take note of the rights from "ls -ld /home/jlb41/public_html"
> then try "chmod 777 /home/jlb41/public_html"
> and try again php for system("date >new_test_file")
Here's what I got back from "chmod 777 /home/jlb41/public_html":
drwxr-xr-x. 11 jlb41 jlb41 4096 Mar 12 14:05 /home/jlb41/public_html
system("date >new_test_file") works through PHP now.
> If it works, then try povray.
I changed the file permissions for object.png to 666 and it works now! Thank you
so much for your help. I really appreciate it!
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |