Bug 232950 - execle in FreeBSD work differ than execle in Linux ?
Summary: execle in FreeBSD work differ than execle in Linux ?
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: gnu (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-04 09:45 UTC by aborche
Modified: 2018-11-04 09:45 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description aborche 2018-11-04 09:45:09 UTC
FreeBSD execle system call works wrong in code written for Linux.

In many Linux sources i see next system call notation like
execle("/sbin/shutdown", "shutdown", "-h", shutdown_flag, "+0",
               "hypervisor initiated shutdown", (char*)NULL, environ);

Where second argument used as short "program name".
In FreeBSD systems, this argument is not bypassed in call and attached to args list.

As a result, when the source is ported to FreeBSD, the system call is not executed correctly.
---- truss output start ----
946: execve("/sbin/shutdown",[ "shutdown", "-h", "-r", "+0", "hypervisor initiated shutdown" ],0x7fffffffeac0) = 0 (0x0)
946: geteuid() = 0 (0x0)
946: write(2,"shutdown: ",10) = 10 (0xa)
946: write(2,"incompatible switches -c, -h, -k"...,43) = 43 (0x2b)
---- truss output end ----

If we change system call to
execle("/sbin/shutdown", "-h", shutdown_flag, "+0",
               "hypervisor initiated shutdown", (char*)NULL, environ);

all is ok.

But, may be this an error in args parsing in FreeBSD "shutdown" ?