(* This requires that the program be running with sufficient capabilities to be *)
(* able to create a unix-domain socket in /var/run and to bind to a port < 1024,*)
(* however immediately after these operations it goes to a lot of trouble to *)
(* relinquish as many privileges as possible. *)
(* *)
(* * If linked with gtk2, it is not possible to run setuid root but explicit *)
(* capabilities may be added during installation: *)
(* *)
(* # setcap CAP_DAC_OVERRIDE,CAP_NET_BIND_SERVICE,CAP_NET_RAW=p+e *gtk2 *)
(* *)
(* Note that capabilities are stored as extended attributes, which DO NOT *)
(* normally accompany a file if it is subsequently copied. *)
(* *)
(* * If linked with Qt, the program may be run setuid root: *)
(* *)
(* # chown root:root *qt *)
(* # chmod u+s *qt *)
(* # chmod g+s *qt *)
(* *)
(* or have extra capabilities as above. *)
(* *)
(* * In any case, the program may be started by the superuser (i.e. run as *)
(* root). *)
(* *)
(* * It may be debugged by being run like *)
(* *)
(* # gdbserver :2345 ./WatchPxx-x86_64-linux-gtk2 *)
(* *)
(* with the Lazarus IDE debugger backend set to remote/gdbserver. *)
(* *)
(* After the ports have been bound, the CAP_DAC_OVERRIDE, CAP_NET_BIND_SERVICE *)
(* and CAP_NET_RAW permitted and effective capabilities are relinquished. If *)
(* the program is running setuid root, then it reverts to the actual user; if *)
(* it is running as root it assumes group and user IDs as given by the *)
(* ownership of the executable, or ID 65534 as ultimate fallback ("nobody" in *)
(* recent Debian releases). MarkMLl. *)