Run CGI scripts with the permissions of their owner.

Odin Kroeger ba255ca1c9 chore: fixed CI config. 7 months ago
.github ba255ca1c9 chore: fixed CI config. 7 months ago
cppcheck 8162aa156e chore: silenced linter warnings. 8 months ago
docs 7397962b09 refactor: massive changes. 9 months ago
scripts 9a56a9fe33 fix: config.h must be copied by hand again. 7 months ago
tests e29d558a3d chore: shortened filenames. 7 months ago
tools 1054253f3f docs: removed superfluous comments. 8 months ago
.gitignore 07e78c6a79 chore: added tmp-*. 8 months ago
LICENSE.txt 9ab4a1c336 chore: first commit. 1 year ago
README.rst fe3c1f0ebd chore: better links for badges. 8 months ago
cattr.h 99a0bc19a6 refactor: wrapped pragmas in compiler checks. 8 months ago
clang-tidy.yml 0afe7f7699 fix: only use _FORTIFY_HEADERS if __OPTIMIZE__ is set. 8 months ago
compat.h.m4 160ac9fcac style: fixed linebreaks. 7 months ago
config.h.ex e29d558a3d chore: shortened filenames. 7 months ago
configure e29d558a3d chore: shortened filenames. 7 months ago
devel.env c43c741717 fix: typos in flags. 8 months ago
dist.excl be40304a35 refactor: simplified macro handling. 8 months ago
env.c e29d558a3d chore: shortened filenames. 7 months ago
env.h b696c9a1c0 refactor: shortened function names. 7 months ago
error.c 0afe7f7699 fix: only use _FORTIFY_HEADERS if __OPTIMIZE__ is set. 8 months ago
error.h 7397962b09 refactor: massive changes. 9 months ago
file.c b696c9a1c0 refactor: shortened function names. 7 months ago
file.h b696c9a1c0 refactor: shortened function names. 7 months ago
handler.c e29d558a3d chore: shortened filenames. 7 months ago
handler.h e29d558a3d chore: shortened filenames. 7 months ago
macros.h 65efc4f9b1 style: replaced tab with spaces. 8 months ago
macros.m4 69451c6152 fix: empty variables count as unset. 8 months ago
main.c e29d558a3d chore: shortened filenames. 7 months ago
makefile.m4 2a247621d6 fix: wrong filename. 7 months ago
max.h 5c31a50d82 fix: re-activated #if clause. 7 months ago
pair.c b696c9a1c0 refactor: shortened function names. 7 months ago
pair.h e29d558a3d chore: shortened filenames. 7 months ago
path.c e29d558a3d chore: shortened filenames. 7 months ago
path.h e29d558a3d chore: shortened filenames. 7 months ago
posix.env 1e989dc2c3 fix: better support for icc. 8 months ago
pregs.h 7397962b09 refactor: massive changes. 9 months ago
prepare ed84459ea5 chore: silenced linter warnings. 8 months ago
priv.c b696c9a1c0 refactor: shortened function names. 7 months ago
priv.h b696c9a1c0 refactor: shortened function names. 7 months ago
prod.env c43c741717 fix: typos in flags. 8 months ago
str.c e29d558a3d chore: shortened filenames. 7 months ago
str.h e29d558a3d chore: shortened filenames. 7 months ago
testing.h 1695e65c46 style: minor changes. 8 months ago
types.h 26442ed4a4 refactor: removed sub-types of ERR_SYS. 8 months ago
userdir.c e29d558a3d chore: shortened filenames. 7 months ago
userdir.h e29d558a3d chore: shortened filenames. 7 months ago

README.rst

|codacy|
|security|
|reliability|
|maintainability|
|coverage|


=====
suCGI
=====

Run CGI scripts with the permissions of their owner.

suCGI checks whether a CGI script is owned by a regular user, sets the real
and the effective UID, the real and the effective GID, and the supplementary
groups of the current process to the UID, the GID, and the supplementary
groups of that user, cleans up the environment, and then runs the script.


Requirements
============

suCGI should work on any system that is compatible with `4.4BSD`_ and
compliant with `POSIX.1-2008`_, including the X/Open System Interface
extension; any Unix-like system that has been released recently-ish
and that does *not* target embedded systems should do.


Installation
============

**Do NOT use suCGI at this point!**
suCGI is work in progess and has *not* been reviewed, let alone audited.

----

Download the repository and unpack it.

Please take the time to read and evaluate the source code.

----

You may need to install:

* A C99 compiler (GCC_ and Clang_ are known to work)
* The header files of your system's standard library
* An assembler and a linker; these are usually packaged as "binary utilities"
(`GNU Binutils`_ and FreeBSD's binary utilities are known to work)
* Make (`GNU Make`_, FreeBSD's Make, and bmake_ are known to work)
* M4 (`GNU M4`_ and FreeBSD's M4 are known to work)

On many systems you can do so by::

sudo ./prepare

``./prepare`` uses the package manager of your operating system, if possible.

----

Generate the *makefile*, *compat.h*, and *config.h* by::

./configure

See `docs/build.rst`_ for details.

----

suCGI is configured at compile-time. Adapt *config.h* to your needs.

----

Compile suCGI by::

make

----

Install suCGI by::

sudo make install

``sudo make install`` will do nothing if suCGI has already been
installed and the installed binary was created or modified more
recently than the binary that has just been built.

You can uninstall suCGI by ``sudo make uninstall``.


Setup
=====

If you are are using Apache_ and want to enable users to run their PHP_
scripts under their own user and group IDs, you can do so by following
these steps.

Enable mod_userdir_::

a2enmod userdir

Enable mod_action_::

a2enmod action

Add the following lines to your Apache configuration::


Action application/x-httpd-php /cgi-bin/sucgi


The directory should correspond to *USER_DIR* in *config.h*.

Restart Apache::

apache2ctl -t && apache2ctl restart


Documentation
=============

See the source code for more details.


Contact
=======

If there's something wrong with suCGI, please
`open an issue `_.


License
=======

Copyright 2022 and 2023 Odin Kroeger

suCGI is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.

suCGI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with suCGI. If not, see .


Further Information
===================

GitHub: https://github.com/odkr/sucgi

.. _4.4BSD: https://docs-legacy.freebsd.org/44doc/

.. _Apache: https://httpd.apache.org/

.. _bmake: https://www.crufty.net/help/sjg/bmake.html

.. _Clang: https://clang.llvm.org/

.. _`docs/build.rst`: docs/build.rst

.. _GCC: https://gcc.gnu.org/

.. _`GNU Binutils`: https://www.gnu.org/software/binutils/

.. _`GNU M4`: https://www.gnu.org/software/m4/

.. _`GNU Make`: https://www.gnu.org/software/make/

.. _mod_action: https://httpd.apache.org/docs/2.4/mod/mod_actions.html

.. _mod_userdir: https://httpd.apache.org/docs/2.4/mod/mod_userdir.html

.. _PHP: https://www.php.net/

.. _`POSIX.1-2008`: https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/

.. |codacy| image:: https://app.codacy.com/project/badge/Grade/cb67a3bad615449589dfb242876600ac
:target: https://www.codacy.com/gh/odkr/sucgi/dashboard?utm_source=github.com&utm_content=odkr/sucgi

.. |coverage| image:: https://sonarcloud.io/api/project_badges/measure?project=odkr_sucgi&metric=coverage
:target: https://sonarcloud.io/component_measures?metric=Coverage&id=odkr_sucgi

.. |security| image:: https://sonarcloud.io/api/project_badges/measure?project=odkr_sucgi&metric=security_rating
:target: https://sonarcloud.io/component_measures?metric=Security&id=odkr_sucgi

.. |reliability| image:: https://sonarcloud.io/api/project_badges/measure?project=odkr_sucgi&metric=reliability_rating
:target: https://sonarcloud.io/component_measures?metric=Reliability&id=odkr_sucgi

.. |maintainability| image:: https://sonarcloud.io/api/project_badges/measure?project=odkr_sucgi&metric=sqale_rating
:target: https://sonarcloud.io/component_measures?metric=Maintainability&id=odkr_sucgi