summaryrefslogtreecommitdiffstats
path: root/proxy/src
Commit message (Collapse)AuthorAgeFilesLines
* getpwman(3) can return NULL without setting errnoRobbie Harwood2015-09-141-0/+3
| | | | | Signed-off-by: Robbie Harwood <rharwood@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Allow configdir and configfile to be specified togetherRobbie Harwood2015-09-141-7/+0
| | | | | | | Not being able to do this is a relic of a previous design. Signed-off-by: Robbie Harwood <rharwood@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Fix formatting on noncompliant copyright linesRobbie Harwood2015-09-0461-1477/+61
| | | | | Signed-off-by: Robbie Harwood <rharwood@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Error on `allow_any_uid` issuesRobbie Harwood (frozencemetery)2015-09-041-1/+43
| | | | | | | | As per gssproxy.conf(5), setting allow_any_uid without also setting socket or selinux_context is known to cause problems. Signed-off-by: Robbie Harwood <rharwood@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Extract generalized selinux context comparison functionRobbie Harwood2015-09-042-13/+26
| | | | | Signed-off-by: Robbie Harwood <rharwood@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Add support for config directoriesRobbie Harwood (frozencemetery)2015-09-044-30/+142
| | | | | | | | | | Option '-C|--configdir' has been added, and defaults to /etc/gssproxy. File "gssproxy.conf" and all files of the form "##-foo.conf" will be read from that directory. Ticket: https://fedorahosted.org/gss-proxy/ticket/122 Signed-off-by: Robbie Harwood <rharwood@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Remove one layer of abstraction over dinglibsRobbie Harwood (frozencemetery)2015-08-313-397/+261
| | | | | | | | A handful of parameter name differences (`key` vs. `keyname`) have been tweaked but the function bodies are otherwise unchanged. Signed-off-by: Robbie Harwood (frozencemetery) <rharwood@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Allow symbolic euids in conf filesRobbie Harwood (frozencemetery)2015-08-261-9/+25
| | | | | | Fixes: https://fedorahosted.org/gss-proxy/ticket/151 Signed-off-by: Robbie Harwood (frozencemetery) <rharwood@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Remove support for iniparse libraryRoland Mainz2015-04-153-258/+0
| | | | | | | | | | This library already does not support some features we need and we want to drop its usage as the code quality is bad. Fixes: https://fedorahosted.org/gss-proxy/ticket/139 Signed-off-by: Roland Mainz <rmainz@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Fix handling of context initializationSimo Sorce2015-03-301-5/+7
| | | | | | | | | | | | | | If a previous call has decided to use only local (to the process) credentials, then we need to override all the way to the end. A previous patch also swapped the order in which credential handler and context handler are initialized, make sure also to swap the fallback checks. Set the behavior to the process default only if it wasn't forced to local. Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Lukas Slebodnik <lslebodn@redhat.com>
* Suppress warning: use after freeLukas Slebodnik2015-03-291-0/+1
| | | | | | | | | | | | | | | | | gssx_ctx is released in case of error. After the latest changes, the old ctx is always replaced to new one and output argument is set. Although it would not be used because return code would not be success it's safer to set NULL to the pointer and avoid warnings from static analyzers. src/client/gpm_init_sec_context.c:108: alias: Assigning: "ctx" = "res->context_handle". Now both point to the same storage. src/client/gpm_init_sec_context.c:156: freed_arg: "free" frees "ctx". src/client/gpm_init_sec_context.c:173: use_after_free: Using freed pointer "ctx". Signed-off-by: Lukas Slebodnik <lslebodn@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Include header file with prototypes in implementation moduleLukas Slebodnik2015-03-291-0/+2
| | | | | | | | | Functions implemented in gp_util.c have prototypes in header file gp_common.h, but it was not included. This patch prevent potential conflicts between ptototype and definition of function. Signed-off-by: Lukas Slebodnik <lslebodn@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Remove unused parameter from get_pipe_nameLukas Slebodnik2015-03-291-2/+2
| | | | | Signed-off-by: Lukas Slebodnik <lslebodn@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Fix warning value stored to 'ret' is never readLukas Slebodnik2015-03-291-1/+2
| | | | | | | | | | | | | | Error: UNUSED_VALUE src/gp_rpc_import_and_canon_name.c:87: value_overwrite: Overwriting previous write to "ret" with value from "gp_conv_status_to_gssx(&icna->call_ctx, ret_maj, ret_min, mech, &icnr->status)". src/gp_rpc_import_and_canon_name.c:52: assigned_value: Assigning value "22" to "ret" here, but that stored value is overwritten before it can be used. Signed-off-by: Lukas Slebodnik <lslebodn@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Suppress exported_composite_name for the kernelSimo Sorce2015-03-241-0/+10
| | | | | | | | | | The kernel makes no use of this data, and ita causes allocation issues in some cases with waste of space on the kernel side. Fixes: https://fedorahosted.org/gss-proxy/ticket/129 Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Nathaniel McCallum <npmccallum@redhat.com>
* Properly handle security contexts on errorSimo Sorce2015-03-245-39/+62
| | | | | | | | | | | | | | | | On error we need to make sure we do not return a pointer to a security context that may have been already freed. So make sure to always unconditionally return the context that we've been returned by our callees. Also reorganize the code so we do not accidently wipe the context and leak memoy on error. This fixed a double-free bug found by NFS folks @ Red Hat Fixes: https://fedorahosted.org/gss-proxy/ticket/137 Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Nathaniel McCallum <npmccallum@redhat.com>
* Fix error in compiling without SELinuxSimo Sorce2015-03-241-10/+9
| | | | | | | | Fixes: #131 Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Nathaniel McCallum <npmccallum@redhat.com> Reviewed-by: Roland Mainz <rmainz@redhat.com>
* Fix cast errorSimo Sorce2015-03-241-1/+3
| | | | | | | | | | An unsigned int cannot be cast to a size_t. On some architectures (like s390) they have different sizes resulting in both writing out of bounds and getting just a zero in the length field and causing the next operation to fail. Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Nathaniel McCallum <npmccallum@redhat.com> Reviewed-by: Roland Mainz <rmainz@redhat.com>
* Log why acquiring credentials failed.Simo Sorce2015-03-241-0/+2
| | | | | | | This will help understanding why gss-proxy interposed programs are failing. Signed-off-by: Simo Sorce <simo@redhat.com>
* Generalize GSS Display Status logger codeSimo Sorce2015-03-243-22/+64
| | | | | | | This way it can be used both in stderr debugging as well as for sending errors to syslog. Signed-off-by: Simo Sorce <simo@redhat.com>
* Zero out the outputs of display_nameSimo Sorce2015-01-221-0/+5
| | | | | | | | | | The mechglue expects the mechanism function to zero them in all cases. Otherwise on error it will later try to free the output buffer value which can be an arbitrary pointer. This will cause a segfault or worse in glibc's free(). Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Roland Mainz <rmainz@redhat.com>
* Fix memory leakLukas Slebodnik2015-01-151-2/+4
| | | | | Signed-off-by: Lukas Slebodnik <lslebodn@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Use defined enum instead of constantLukas Slebodnik2015-01-151-3/+3
| | | | | | | | Value of enum gp_rpc_accept_status GP_RPC_SUCCESS is 0 Value of enum gp_rpc_reject_status GP_RPC_RPC_MISMATCH is 0 Signed-off-by: Lukas Slebodnik <lslebodn@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Wrong coversion function was usedLukas Slebodnik2015-01-151-1/+1
| | | | | Signed-off-by: Lukas Slebodnik <lslebodn@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Suppress clang warningLukas Slebodnik2015-01-151-1/+1
| | | | | | | | Result of 'malloc' is converted to a pointer of type 'uint32_t', which is incompatible with sizeof operand type 'int32_t' Signed-off-by: Lukas Slebodnik <lslebodn@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Add cmdline option to override default socketSimo Sorce2014-09-153-4/+14
| | | | | | | | This is especially useful for testing, but can be useful for custom configurations of gss-proxy as well (containers, chroots, etc..) Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Guenther Deschner <gdeschner@redhat.com>
* Properly cleanup mutex on failure.Simo Sorce2014-03-121-0/+3
| | | | | | | | | | If the call to create socket fails we leave a dangling lock and the client enters into a deadlock on the next call. Fixes: https://fedorahosted.org/gss-proxy/ticket/121 Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Fix potential segfault in gssi_inquire_context().Günther Deschner2014-02-051-2/+2
| | | | | Signed-off-by: Günther Deschner <gdeschner@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Block parent process until child is initialized.Simo Sorce2014-01-153-6/+50
| | | | | | | | | | | | This way the init system will not proceed starting dependencies until gssproxy is actually ready to serve requests. In particular this is used to make sure the nfsd proc file has been touched before the nfsd server is started. Resolves: https://fedorahosted.org/gss-proxy/ticket/114 Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Add utility functions to read()/write() safelySimo Sorce2014-01-152-0/+41
| | | | | | | Automatically handle short reads due to singals interrupting the process. Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Make name conversion more robust to failureSimo Sorce2014-01-151-10/+14
| | | | | | | | | | | | | | | | NTLMSSP does not have export_name functions yet, this was causing gss_export_composite_name() to fail with a GSS_S_UNAVAILABLE error. This should be ignored, however it wasn't and on top of that the output structure was initialized but held pointers to memory freed at exit (due to the error). Make the function not failed if a mechanism do not have composite export function, but if it does make sure the output is not littered with invalid pointers. Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Add zero termination when the buffer is a stringSimo Sorce2014-01-153-1/+24
| | | | | | | | | | | | | This shouldn't be needed but apaprently there are a number of applications like mod_auth_kerb that just blindly assume the out buffer returned by gss_diplay_name() is a zero terminated string even though there is no guarantee it is in the API. To avoid annoying misbehavior we forcibly zero terminate strings copied and returned by the interposer. Fixes: https://fedorahosted.org/gss-proxy/ticket/101 Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Add support for dropping privilegesSimo Sorce2014-01-144-0/+66
| | | | | | | | | | | | | | If the 'proxy user' configuation option is set in the [gssproxy] section then GSS Proxy will drop privileges to the specified after setting up all the sockets. Care must be taken to make sure all the resources the daemon need access to (keytabs, ccache directories, etc..) are accessible as the proxy user. Implements: https://fedorahosted.org/gss-proxy/ticket/102 Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Fix config token parsing.Simo Sorce2013-12-091-1/+0
| | | | | | | Resolves: https://fedorahosted.org/gss-proxy/ticket/112 Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Use gp_strerror() everywhere instead of strerror()Simo Sorce2013-11-225-17/+17
| | | | | | https://fedorahosted.org/gss-proxy/ticket/111 Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Add Thread-safe implementation of strerror()Simo Sorce2013-11-222-0/+62
| | | | | | | | | | | | Unfortunately strerror() is not thread safe so we have to juggle with strerror_r() which is a can of worms as 2 incompatible implementations are available depending on what is defined at compile time. Try to do something sane. https://fedorahosted.org/gss-proxy/ticket/111 Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Use secure_getenv in client and mechglue moduleSimo Sorce2013-11-214-3/+24
| | | | | | | | | | proxymehc.so may be used in setuid binaries so follow best security practices and use secure_getenv() if available. Fallback to poorman emulation when secure_getenv() is not available. Resolves: https://fedorahosted.org/gss-proxy/ticket/110 Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* creds: Allow admins to define only client credsSimo Sorce2013-11-201-1/+6
| | | | | | | When a service is configured with cred_usage = initiate it is ok to allow only client credentials to be defined. Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* config: Do not modify const stringsSimo Sorce2013-11-201-1/+9
| | | | | | | Take a copy here, the option string is const and strtok_r() is not a safe function as it may change the string it manipulates. Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* server: Implement flag filtering enforcementSimo Sorce2013-11-203-0/+11
| | | | | | Resolves: https://fedorahosted.org/gss-proxy/ticket/109 Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* config: Add code to source flag filtersSimo Sorce2013-11-202-0/+90
| | | | | | | | | | | | | | | | | | | 2 New configuration options are made available: - filter_flags - enforce_flags Any GSS Flags listed in the filter_flags option is forcibly filtered out before a gss_init_sec_context() call is invoked. Any GSS Flags listed in the enforce_flags option is forcibly added to the list of flags requested by a gss_init_sec_context() call is invoked. Flags can be either literals or numeric and must be preceded by the sign + (to add to the list) or - (to remove from the list). Resolves: https://fedorahosted.org/gss-proxy/ticket/109 Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Try impersonation even when a name is not providedSimo Sorce2013-11-201-0/+5
| | | | | | | In some cases a name may not be provided, still try to perform impersonation if the service is configured that way. Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Autoinitialize creds on init_sec_contextSimo Sorce2013-11-201-6/+19
| | | | | | | | If the remote client tries to initialize the context without first acquiring credentials, try to acquire appropriate credentials if the service allows it. Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Fix continuations in context establishment callsSimo Sorce2013-11-199-24/+77
| | | | | | | | | | | | Properly support continuations, including returning the rigth error code and exporting partial contexts. Fixes multistep authentications in particular for the initialization case which always uses continuations. Resolves: https://fedorahosted.org/gss-proxy/ticket/108 Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Fix calling gpm_inquire_cred_by_mechSimo Sorce2013-11-191-1/+2
| | | | | | | | | | | We need to pass the real mechanism oid here, not the spcial oid. special oids are used exclusively by the interposer and gssapi machinery that calls the interposer, they must never be propagated to clients or servers. https://fedorahosted.org/gss-proxy/ticket/107 Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Add way to return regular oid from specialSimo Sorce2013-11-192-13/+43
| | | | | | | | | | In some cases we need to pass on the corresponding real oid, after we are given a special oid. Add helper functions to do that. https://fedorahosted.org/gss-proxy/ticket/107 Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Preserve requested flags and lifetimeSimo Sorce2013-11-191-0/+3
| | | | | | | | | These arguments have been accidentally forgotten causing failures for applications that specify non default flags and non indefinite lifetime. https://fedorahosted.org/gss-proxy/ticket/106 Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Add impersonation supportSimo Sorce2013-10-233-55/+165
| | | | | | | | | | | | | By setting the impersonate flag to true, the acquisition of credentials will be done using constrained delegation (s4uself + s4u2proxy). To work this needs MIT Kereberos 1.11.4 or later. Previous versions have a bug in the import_cred function that prevents the library from properly importing previously exported delegated credentials. Resolves: https://fedorahosted.org/gss-proxy/ticket/95 Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Move uid to name resolution in its own function.Simo Sorce2013-10-231-6/+19
| | | | Reviewed-by: Günther Deschner <gdeschner@redhat.com>
* Add option to specify allowed usage.Simo Sorce2013-10-183-2/+32
| | | | | | | | | | Credentials can often be used both to accept and to initiate contexts. With this option admins can allow a specific usage only. This is to avoid allowing an unprivileged process to fool a remote client by allowing it to impersonate a server, when we only want to allow this service to use credentials to initiate contexts. Reviewed-by: Günther Deschner <gdeschner@redhat.com