Re: what happens if

2012-03-21 Thread Erez D
2012/3/20 Diego Iastrubni elc...@kde.org

 On יום שלישי 20 מרץ 2012 10:45:19 Erez D wrote:
   All theory I read before implementing this said this was a bad idea.
 The
   theory says that libc may maintain some mutex inside malloc() which is
   called
   from printf() for example. This means that even trivial things may kill
   your
   app. The theory says that in multithreaded applications as soon as you
   clone()
   (the system called used by pthread_create()) you should execvp.
  
   In my application (a lot of C++, running on linux 2.6.32, glibc 2.9 and
   glibc
   2.11.1 on ARM) erverything worked perfectly against the theory, your
   mileage
   may vary.
 
  what do you mean by  erverything worked perfectly against the theory -
  did it work or did you have problems although you just execvp after
 clone ?
 Sorry, to be clear:

 I cloned(), then forked(), but no exec*() was called in the new child
 process.

doesn't clone() and fork()  do similar things ? why fork() after clone() ?


 Everything worked fine in my setup. But again, YMMV.

___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: what happens if

2012-03-20 Thread Erez D
2012/3/19 Diego Iastrubni elc...@kde.org

 On יום שני 19 מרץ 2012 12:22:15 Erez D wrote:
  On Mon, Mar 19, 2012 at 12:20 PM, Nadav Har'El
 n...@math.technion.ac.ilwrote:
   On Mon, Mar 19, 2012, Erez D wrote about Re: what happens if:
my reason for fork is only for exec() - to protect the first program
from the other.
  
   Then you should be all fine.

 Another reason is for interacting with libraries which are singleton. I
 had
 to work with a library to talk to some special HW. The library was
 designed to
 work with one device per process, and I needed to support many.

 I found myself forking and using pipe() to use the API from my main app.
 The
 problem is that that fork() was called from a thread. Read ahead.

   If you're talking about the C language, you won't have any of these
   problems. System calls like close() or dup() do not use any pthread
   capabilities like mutexes.
  
   If you're talking about a different programming language, I frankly
   have no idea what its fork() does. Maybe you need to write some C
   code that does fork()/exec() in one function call, and avoid this risk.
 
  i will be using C++. are you sure this is safe ?

 All theory I read before implementing this said this was a bad idea. The
 theory says that libc may maintain some mutex inside malloc() which is
 called
 from printf() for example. This means that even trivial things may kill
 your
 app. The theory says that in multithreaded applications as soon as you
 clone()
 (the system called used by pthread_create()) you should execvp.

 In my application (a lot of C++, running on linux 2.6.32, glibc 2.9 and
 glibc
 2.11.1 on ARM) erverything worked perfectly against the theory, your
 mileage
 may vary.

what do you mean by  erverything worked perfectly against the theory -
did it work or did you have problems although you just execvp after clone ?


 ___
 Linux-il mailing list
 Linux-il@cs.huji.ac.il
 http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il

___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: what happens if

2012-03-20 Thread Diego Iastrubni
On יום שלישי 20 מרץ 2012 10:45:19 Erez D wrote:
  All theory I read before implementing this said this was a bad idea. The
  theory says that libc may maintain some mutex inside malloc() which is
  called
  from printf() for example. This means that even trivial things may kill
  your
  app. The theory says that in multithreaded applications as soon as you
  clone()
  (the system called used by pthread_create()) you should execvp.
  
  In my application (a lot of C++, running on linux 2.6.32, glibc 2.9 and
  glibc
  2.11.1 on ARM) erverything worked perfectly against the theory, your
  mileage
  may vary.
 
 what do you mean by  erverything worked perfectly against the theory -
 did it work or did you have problems although you just execvp after clone ?
Sorry, to be clear:

I cloned(), then forked(), but no exec*() was called in the new child process. 

Everything worked fine in my setup. But again, YMMV.

___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


what happens if

2012-03-19 Thread Erez D
what happens if i am running a multithreaded app ( 3 threads ) and one
thread calls fork() ?
___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: what happens if

2012-03-19 Thread Baruch Siach
Hi Erez,

On Mon, Mar 19, 2012 at 10:47:20AM +0200, Erez D wrote:
 what happens if i am running a multithreaded app ( 3 threads ) and one
 thread calls fork() ?

See pthread_atfork(3).

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: what happens if

2012-03-19 Thread ronys
FTFM:
The  child  process  is  created with a single thread - the one
that called fork().


2012/3/19 Erez D erez0...@gmail.com

 what happens if i am running a multithreaded app ( 3 threads ) and one
 thread calls fork() ?

 ___
 Linux-il mailing list
 Linux-il@cs.huji.ac.il
 http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il




-- 
Ubi dubium, ibi libertas (where there is doubt, there is freedom)
___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: what happens if

2012-03-19 Thread Nadav Har'El
On Mon, Mar 19, 2012, Erez D wrote about what happens if:
 what happens if i am running a multithreaded app ( 3 threads ) and one
 thread calls fork() ?

On Linux, the new process will run ONLY a copy of the thread doing the
fork(). The other threads are *not* copied to the child process.

There is no way in Linux to ask to duplicate all of the process's
threads, as in Solaris's forkall(2) system call. Even if such a
system call existed, its usefulness would be dubious as explained 
in Posix's fork(2) manual:
http://pubs.opengroup.org/onlinepubs/009695399/functions/fork.html
(look for the section starting in The addition of the forkall()
function to the standard was considered and rejected.)

All this makes fork() more or less useless for multithreaded
applications except for one idiom: fork() followed by exec().


-- 
Nadav Har'El|Monday, Mar 19 2012, 
n...@math.technion.ac.il |-
Phone +972-523-790466, ICQ 13349191 |This space is for sale - inquire inside.
http://nadav.harel.org.il   |

___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: what happens if

2012-03-19 Thread Erez D
On Mon, Mar 19, 2012 at 11:40 AM, Nadav Har'El n...@math.technion.ac.ilwrote:

 On Mon, Mar 19, 2012, Erez D wrote about what happens if:
  what happens if i am running a multithreaded app ( 3 threads ) and one
  thread calls fork() ?

 On Linux, the new process will run ONLY a copy of the thread doing the
 fork(). The other threads are *not* copied to the child process.

 There is no way in Linux to ask to duplicate all of the process's
 threads, as in Solaris's forkall(2) system call. Even if such a
 system call existed, its usefulness would be dubious as explained
 in Posix's fork(2) manual:
http://pubs.opengroup.org/onlinepubs/009695399/functions/fork.html
 (look for the section starting in The addition of the forkall()
 function to the standard was considered and rejected.)

 All this makes fork() more or less useless for multithreaded
 applications except for one idiom: fork() followed by exec().

my reason for fork is only for exec() - to protect the first program from
the other.
the problem that may arise in forking a multithreaded is that one thread
may lock a mutex and then another call for fork, which means that the child
inherits the locked mutex.
i do not know internaly what library function use this mutex, e.g. will
close() need this mutex ? will dup() will ? in this case, trying to close a
side of a pipe, duping it or even closing open fds (for security issues)
may hang the child while the library waits for the mutex , and no other
thread exists in the child to release it

a only way to resolve it, is to fork to another process before generating
the other threads, the second process will be left  single threaded and so
may fork() with no problems, but this way i can't use pipe(), and need to
revert to named pipe which is ugly

any pther ideas ? things i missed ?



 --
 Nadav Har'El|Monday, Mar 19
 2012,
 n...@math.technion.ac.il
 |-
 Phone +972-523-790466, ICQ 13349191 |This space is for sale - inquire
 inside.
 http://nadav.harel.org.il   |

___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: what happens if

2012-03-19 Thread Nadav Har'El
On Mon, Mar 19, 2012, Erez D wrote about Re: what happens if:
 my reason for fork is only for exec() - to protect the first program from
 the other.

Then you should be all fine.

 the problem that may arise in forking a multithreaded is that one thread
 may lock a mutex and then another call for fork, which means that the child
 inherits the locked mutex.
 i do not know internaly what library function use this mutex, e.g. will
 close() need this mutex ? will dup() will ? in this case, trying to close a
 side of a pipe, duping it or even closing open fds (for security issues)
 may hang the child while the library waits for the mutex , and no other
 thread exists in the child to release it

If you're talking about the C language, you won't have any of these
problems. System calls like close() or dup() do not use any pthread
capabilities like mutexes.

If you're talking about a different programming language, I frankly
have no idea what its fork() does. Maybe you need to write some C
code that does fork()/exec() in one function call, and avoid this risk.

Did actually notice any problem with your code, or is this question
just theoretical?

-- 
Nadav Har'El|Monday, Mar 19 2012, 
n...@math.technion.ac.il |-
Phone +972-523-790466, ICQ 13349191 |If God had intended us to be vegetarians,
http://nadav.harel.org.il   |He wouldn't have made animals out of meat

___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: what happens if

2012-03-19 Thread Erez D
On Mon, Mar 19, 2012 at 12:20 PM, Nadav Har'El n...@math.technion.ac.ilwrote:

 On Mon, Mar 19, 2012, Erez D wrote about Re: what happens if:
  my reason for fork is only for exec() - to protect the first program from
  the other.

 Then you should be all fine.

  the problem that may arise in forking a multithreaded is that one thread
  may lock a mutex and then another call for fork, which means that the
 child
  inherits the locked mutex.
  i do not know internaly what library function use this mutex, e.g. will
  close() need this mutex ? will dup() will ? in this case, trying to
 close a
  side of a pipe, duping it or even closing open fds (for security issues)
  may hang the child while the library waits for the mutex , and no other
  thread exists in the child to release it

 If you're talking about the C language, you won't have any of these
 problems. System calls like close() or dup() do not use any pthread
 capabilities like mutexes.

 If you're talking about a different programming language, I frankly
 have no idea what its fork() does. Maybe you need to write some C
 code that does fork()/exec() in one function call, and avoid this risk.

i will be using C++. are you sure this is safe ?


 Did actually notice any problem with your code, or is this question
 just theoretical?

theoretical


 --
 Nadav Har'El|Monday, Mar 19
 2012,
 n...@math.technion.ac.il
 |-
 Phone +972-523-790466, ICQ 13349191 |If God had intended us to be
 vegetarians,
 http://nadav.harel.org.il   |He wouldn't have made animals out of
 meat

___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: what happens if

2012-03-19 Thread Nadav Har'El
On Mon, Mar 19, 2012, Erez D wrote about Re: what happens if:
  If you're talking about the C language, you won't have any of these
  problems. System calls like close() or dup() do not use any pthread
  capabilities like mutexes.
..
 i will be using C++. are you sure this is safe ?

I'm sure. But don't sue me if I'm wrong ;-)

-- 
Nadav Har'El|Monday, Mar 19 2012, 
n...@math.technion.ac.il |-
Phone +972-523-790466, ICQ 13349191 |Disclaimer: The opinions expressed above
http://nadav.harel.org.il   |are not my own.

___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: what happens if

2012-03-19 Thread Erez D
On Mon, Mar 19, 2012 at 12:25 PM, Nadav Har'El n...@math.technion.ac.ilwrote:

 On Mon, Mar 19, 2012, Erez D wrote about Re: what happens if:
   If you're talking about the C language, you won't have any of these
   problems. System calls like close() or dup() do not use any pthread
   capabilities like mutexes.
 ..
  i will be using C++. are you sure this is safe ?

 I'm sure. But don't sue me if I'm wrong ;-)

I wont
thanks


 --
 Nadav Har'El|Monday, Mar 19
 2012,
 n...@math.technion.ac.il
 |-
 Phone +972-523-790466, ICQ 13349191 |Disclaimer: The opinions expressed
 above
 http://nadav.harel.org.il   |are not my own.

___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: what happens if

2012-03-19 Thread Diego Iastrubni
On יום שני 19 מרץ 2012 12:22:15 Erez D wrote:
 On Mon, Mar 19, 2012 at 12:20 PM, Nadav Har'El 
n...@math.technion.ac.ilwrote:
  On Mon, Mar 19, 2012, Erez D wrote about Re: what happens if:
   my reason for fork is only for exec() - to protect the first program
   from the other.
  
  Then you should be all fine.

Another reason is for interacting with libraries which are singleton. I had 
to work with a library to talk to some special HW. The library was designed to 
work with one device per process, and I needed to support many.

I found myself forking and using pipe() to use the API from my main app. The 
problem is that that fork() was called from a thread. Read ahead.

  If you're talking about the C language, you won't have any of these
  problems. System calls like close() or dup() do not use any pthread
  capabilities like mutexes.
  
  If you're talking about a different programming language, I frankly
  have no idea what its fork() does. Maybe you need to write some C
  code that does fork()/exec() in one function call, and avoid this risk.
 
 i will be using C++. are you sure this is safe ?

All theory I read before implementing this said this was a bad idea. The 
theory says that libc may maintain some mutex inside malloc() which is called 
from printf() for example. This means that even trivial things may kill your 
app. The theory says that in multithreaded applications as soon as you clone() 
(the system called used by pthread_create()) you should execvp.

In my application (a lot of C++, running on linux 2.6.32, glibc 2.9 and glibc 
2.11.1 on ARM) erverything worked perfectly against the theory, your mileage 
may vary.

___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: Kernel question - what happens when a shell script is the interpreter for another shell script?

2008-03-23 Thread Dan Kenigsberg
On Thu, Mar 20, 2008 at 07:25:19PM +0200, Shachar Shemesh wrote:
 Valery Reznic wrote:
 
  Below is important part
 
If  the  header  of  a  file  isn?t recognized
 (the attempted execve(2)
returned ENOEXEC), these functions will 
 execute  the  shell  (/bin/sh)
with  the  path  of  the  file as its first
 argument.  (If this attempt
fails, no further searching is done.)
   
 Yes, I do believe you nailed it.
 
 After Matan's email I tried running the set with strace, and realized it 
 was, indeed, a user space thing. As I need that for a (user space) 
 program that intercepts the actual kernel calls (and sometimes emulates 
 them), I will assume that the governing rule is that a program can have 
 just one shell script in its interpreter path.
 
 And now to a slightly related subject - does anyone know how I can 
 change the command line that appears in ps for a program after it has 
 been run? I know it should be possible, because I vaguely remember 
 programs that receive sensitive information in command line and try to 
 immediately hide it, but merely writing to the argv addresses did not 
 bring the desired results, and /proc/self/cmdline seems to be read only.

I happenned to stumble on this question recently.

prctl(2) has PR_SET_NAME. An even simpler solution, that may work on non-Linux
too and may be good enough, is softlink.

-- 
Dan Kenigsberghttp://www.cs.technion.ac.il/~dankenICQ 162180901

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: Kernel question - what happens when a shell script is the interpreter for another shell script?

2008-03-23 Thread Shachar Shemesh

Dan Kenigsberg wrote:



I happenned to stumble on this question recently.

prctl(2) has PR_SET_NAME. An even simpler solution, that may work on non-Linux
too and may be good enough, is softlink.

  

From the prctl man page:

CONFORMING TO
   This call is Linux-specific.  IRIX has a prctl() system call 
(also introduced in Linux 2.1.44 as irix_prctl on the MIPS 
architecture), with pro-

   totype


So, it seems that writing to the argv buffer may, actually, be more 
platform indep than the alternative.


Shachar

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Kernel question - what happens when a shell script is the interpreter for another shell script?

2008-03-20 Thread Shachar Shemesh

Hi all,


I tried the following experiment. /tmp/file1 (marked executable) has the
following content:

#!/bin/date


echo $@


/tmp/file2 has the following content:

#!/tmp/file1


echo File2


when I run file2, I expect it to print out the current date. Instead, it
prints out File2. In other words, it goes to /bin/sh to execute.


I tried going over the kernel code that handles this, but I must be
looking at the wrong place. I got as far as the function load_script
(fs/binfmt_script.c line 18 in the 2.6.23 kernel code), which seems to
go over the file, extract the interpreter, and restart the entire
process. Of course, once the process has restarted, bprm-sh_bang is not
zero (line 25 of the file), and the function returns ENOEXEC. This
explains why a shell script cannot be the interpreter for a shell script.


What is not explained, however, is what does happen. I have not been
able to locate what happens when the kernel runs out of functions that
may make sense of the file we try to execute (aside from returning
ENOEXEC, which does not seem to be what is actually happening). I have
also been unable to locate where in the source there is any special
casing of /bin/sh (aside from when the kernel cannot find /sbin/init,
/etc/init and /bin/init during boot).


What's going on here?


Shachar



=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: Kernel question - what happens when a shell script is the interpreter for another shell script?

2008-03-20 Thread Omer Zak
Did you add /tmp/file1 to the list in /etc/shells?

On Thu, 2008-03-20 at 16:23 +0200, Shachar Shemesh wrote:
 Hi all,
 
 
 I tried the following experiment. /tmp/file1 (marked executable) has the
 following content:
 
 #!/bin/date
 
 
 echo $@
 
 
 /tmp/file2 has the following content:
 
 #!/tmp/file1
 
 
 echo File2
 
 
 when I run file2, I expect it to print out the current date. Instead, it
 prints out File2. In other words, it goes to /bin/sh to execute.

-- 
MS-Windows is the Pal-Kal of the PC world.
My own blog is at http://www.zak.co.il/tddpirate/

My opinions, as expressed in this E-mail message, are mine alone.
They do not represent the official policy of any organization with which
I may be affiliated in any way.
WARNING TO SPAMMERS:  at http://www.zak.co.il/spamwarning.html


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: Kernel question - what happens when a shell script is the interpreter for another shell script?

2008-03-20 Thread Matan Ziv-Av

On Thu, 20 Mar 2008, Shachar Shemesh wrote:


Hi all,


I tried the following experiment. /tmp/file1 (marked executable) has the
following content:

#!/bin/date


echo $@


/tmp/file2 has the following content:

#!/tmp/file1


echo File2


when I run file2, I expect it to print out the current date. Instead, it


Why? Does that happen when you run /tmp/file1?


prints out File2. In other words, it goes to /bin/sh to execute.


Try replacing echo with sleep 60, and run pstree in another shell.

Try running /tmp/file2 from zsh instead of bash (or tcsh). This will 
give you a clue about which source you need to scrutinize.



--
Matan Ziv-Av. [EMAIL PROTECTED]


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: Kernel question - what happens when a shell script is the interpreter for another shell script?

2008-03-20 Thread Valery Reznic
Hi, Shachar.

You look at correct place and got everything right.
Almost. OK, everything you look kernel side is OK.

When you run program from the shell, shell use
not execve, but execvp (or execlp)

from the man execve 

===
Special semantics for execlp() and execvp()
   The  functions  execlp() and execvp() will
duplicate the actions of the
   shell in searching for an executable file  if 
the  specified  filename
   does  not  contain  a slash (/) character.  The
search path is the path
   specified in the environment by the PATH
variable.   If  this  variable
   isn’t specified, the default path
‘‘:/bin:/usr/bin’’ is used.  In addi-
   tion, certain errors are treated specially.

   If permission is denied for a file (the 
attempted  execve(2)  returned
   EACCES), these functions will continue
searching the rest of the search
   path.  If no other file is found, however, they
will  return  with  the
   global variable errno set to EACCES.


 Below is important part

   If  the  header  of  a  file  isn’t recognized
(the attempted execve(2)
   returned ENOEXEC), these functions will 
execute  the  shell  (/bin/sh)
   with  the  path  of  the  file as its first
argument.  (If this attempt
   fails, no further searching is done.)
===

If you use compile program
#include stdlib.h

int main(int argc, char *argv[], char *envp[])
{
execve(argv[1], argv[1], envp);
}

and run  it  under strace
strace program /tmp/file2
You'll see, that execve return ENOEXEC, as it should
(and as you saw in the kernel sources)

Regards,
Valery.



--- Shachar Shemesh [EMAIL PROTECTED] wrote:

 Hi all,
 
 
 I tried the following experiment. /tmp/file1 (marked
 executable) has the
 following content:
 
 #!/bin/date
 
 
 echo $@
 
 
 /tmp/file2 has the following content:
 
 #!/tmp/file1
 
 
 echo File2
 
 
 when I run file2, I expect it to print out the
 current date. Instead, it
 prints out File2. In other words, it goes to
 /bin/sh to execute.
 
 
 I tried going over the kernel code that handles
 this, but I must be
 looking at the wrong place. I got as far as the
 function load_script
 (fs/binfmt_script.c line 18 in the 2.6.23 kernel
 code), which seems to
 go over the file, extract the interpreter, and
 restart the entire
 process. Of course, once the process has restarted,
 bprm-sh_bang is not
 zero (line 25 of the file), and the function returns
 ENOEXEC. This
 explains why a shell script cannot be the
 interpreter for a shell script.
 
 
 What is not explained, however, is what does happen.
 I have not been
 able to locate what happens when the kernel runs out
 of functions that
 may make sense of the file we try to execute (aside
 from returning
 ENOEXEC, which does not seem to be what is actually
 happening). I have
 also been unable to locate where in the source there
 is any special
 casing of /bin/sh (aside from when the kernel cannot
 find /sbin/init,
 /etc/init and /bin/init during boot).
 
 
 What's going on here?
 
 
 Shachar
 
 
 

=
 To unsubscribe, send mail to
 [EMAIL PROTECTED] with
 the word unsubscribe in the message body, e.g.,
 run the command
 echo unsubscribe | mail
 [EMAIL PROTECTED]
 
 



  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: Kernel question - what happens when a shell script is the interpreter for another shell script?

2008-03-20 Thread Shachar Shemesh

Valery Reznic wrote:


 Below is important part

   If  the  header  of  a  file  isn’t recognized
(the attempted execve(2)
   returned ENOEXEC), these functions will 
execute  the  shell  (/bin/sh)

   with  the  path  of  the  file as its first
argument.  (If this attempt
   fails, no further searching is done.)
  

Yes, I do believe you nailed it.

After Matan's email I tried running the set with strace, and realized it 
was, indeed, a user space thing. As I need that for a (user space) 
program that intercepts the actual kernel calls (and sometimes emulates 
them), I will assume that the governing rule is that a program can have 
just one shell script in its interpreter path.


And now to a slightly related subject - does anyone know how I can 
change the command line that appears in ps for a program after it has 
been run? I know it should be possible, because I vaguely remember 
programs that receive sensitive information in command line and try to 
immediately hide it, but merely writing to the argv addresses did not 
bring the desired results, and /proc/self/cmdline seems to be read only.


Shachar

To unsubscribe, 
send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: Kernel question - what happens when a shell script is the interpreter for another shell script?

2008-03-20 Thread Yedidyah Bar-David
On Thu, Mar 20, 2008 at 07:25:19PM +0200, Shachar Shemesh wrote:
 And now to a slightly related subject - does anyone know how I can 
 change the command line that appears in ps for a program after it has 
 been run? I know it should be possible, because I vaguely remember 
 programs that receive sensitive information in command line and try to 
 immediately hide it, but merely writing to the argv addresses did not 
 bring the desired results, 

Are you sure? This works for me:
 strncpy(argv[0], test123 456, strlen(argv[0]));
But this doesn't:
 argv[0] = test123 456;
Make sure you get it right.
-- 
Didi


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



set what happens when I do poweroff

2000-12-15 Thread David Hananel

Hello guys..
Sorry for all of the questions...

I would like to know if I can set whats happening when I do "poweroff" or
"halt" or "shutdown -h now"

I thought maby I should reconfigure something there to fix the Power off
thing... Cause apm is working great at my PC...
If I do "apm --standby" for example, it's moving to a standby position...

So I would like to know if I can change the proccess of the shutdown...

Thanks,
David


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]