Bug 119039

Summary: initreq.h should be installed
Product: [Fedora] Fedora Reporter: Nathan Robertson <nathanr>
Component: sysvinitAssignee: Bill Nottingham <notting>
Status: CLOSED RAWHIDE QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: bnocera, rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 2.86-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-12-19 16:00:39 EST Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Attachments:
Description Flags
adds initreq.h to the RPM none

Description Nathan Robertson 2004-03-24 02:10:15 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1)
Gecko/20031114 Epiphany/1.0.4

Description of problem:
initreq.h is a header file which is required by pbbuttonsd, a package
for controlling power management and the "extra keys" that do things
like volume, brightness, etc. on laptops (i386 and ppc). This header
file basically contains one structure which said program needs, and
there's no reason not to export it to /usr/include. See the attached
patch.

After this patch is applied, I can package up pbbuttonsd for FC.

Version-Release number of selected component (if applicable):
SysVinit-2.85-21

How reproducible:
Always

Steps to Reproduce:
1. Try to compile a program which #include's <initreq.h>


Additional info:
Comment 1 Nathan Robertson 2004-03-24 02:14:34 EST
Created attachment 98817 [details]
adds initreq.h to the RPM

Of course, header files belong in -devel packages, but it seems hardly worth it
for one very small header file. If the maintainer feels it's worth it, I guess
technically it should be split up.
Comment 2 Bill Nottingham 2004-03-24 11:38:10 EST
Why do the volume/brightness buttons need to signal *init*?
Comment 3 Nathan Robertson 2004-03-24 16:31:57 EST

int
The daemon has two functions:
- those buttons
- power management

init is used in the latter function. More specifically, here's where
it's used to send SIGPWR to init:

send_sigpwr (char mode)
{
  struct init_request initreq;
  FILE *fd;
  int err = -1;
                                                                     
          
  initreq.magic     = INIT_MAGIC;
  initreq.cmd       = mode == 'F' ? INIT_CMD_POWERFAIL : INIT_CMD_POWEROK;
  initreq.sleeptime = 5;
                                                                     
          
  if ((fd = fopen(INIT_FIFO, "r+")) != NULL) {
    err = 0;
    if ((fwrite(&initreq, sizeof(initreq), 1, fd)) != 1)
      err = -1;
    fclose(fd);
  }
  if (err == -1) {
    if ((fd = fopen("/etc/powerstatus", "w")) != NULL) {
      err = 0;
      if ((fwrite(&mode, 1, 1, fd)) != 1)
        err = -1;
      fclose(fd);
    }
    err = kill(1, SIGPWR);  /* send SIGPWR to the INIT process */
  }
  return err;
}
Comment 4 Bill Nottingham 2004-03-25 00:52:55 EST
Hm, it would be simpler if those were gated through the same mechanism
as the ACPI buttons.
Comment 5 Nathan Robertson 2004-03-25 16:49:23 EST
I forwarded on this bug report to the author of pbbuttonsd. Here is
his response:

---------------------------------------------------------------------
pbbuttonsd is a power management daemon for apple powerpc machines 
which don't support ACPI. 
 
PBButtonsd can be configured to tell init about the low battery 
condition. Init has appropriate mechanisms to handle such emergency 
conditions. Usually an application writes the file /etc/powerstatus 
and send the signal SIGPWR to the init process but the man page of 
init (8) depreciated this method: 
--- quote --- 
Usage of SIGPWR and /etc/powerstatus is discouraged. Someone 
wanting to interact with init should use the /dev/initctl 
control channel - see the source code of the sysvinit package 
for more documentation about this. 
--- quote off --- 
You see installing the include file initreq.h is a step forward. 
 
 Best Regards 
   Matthias Grimm 
---------------------------------------------------------------------
Comment 6 Nathan Robertson 2004-03-25 17:00:07 EST
Also from the init man page:

[quote]
INTERFACE
Init  listens  on  a fifo in /dev, /dev/initctl, for messages. 
Telinit uses this to communicate with init. The interface is not very
well documented or finished. Those interested should study the
initreq.h file in the src/ subdirectory of the init source code tar
archive.
[/quote]

So, to use the /dev/initctl interface, you need the header that patch
provides. From initreq.h:

#define INIT_FIFO "/dev/initctl"

and from the code listing above:

if ((fd = fopen(INIT_FIFO, "r+")) != NULL)

So, this looks like the recommended way, from reading the man page.
Comment 7 Bill Nottingham 2004-03-25 17:05:35 EST
Yes, it's just that there are also acpi-using buttons for doing
soft-power off. In the Grand Scheme, it would be nice to have them all
going through the same interface. :)
Comment 8 Nathan Robertson 2004-03-26 01:25:35 EST
That may well be so (or not, my knowledge is limited in this area).

However, either way, the initreq.h header should be included in any
case, because it's inconsistent with the init(8) man page not to
include it. The man page says "we recommend you do this, see this
header file" (ie. use what's in there, implying #include it). Without
the header file included, there is no way *any* application could
follow the recommended practice from the man page.

Whether or not pbbuttonsd should be using this header file is another
discussion, I guess.
Comment 9 Bill Nottingham 2005-12-19 16:00:39 EST
Will be fixed in 2.86-1.
Comment 10 David Lawrence 2007-06-21 22:10:40 EDT
Package name is now sysvinit in Fedora.