Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 632243 Details for
Bug 838898
With SELInux enabled, `service cobblerd start` fails with AVC message and "CFUNCTYPE(c_int)(lambda: None)" MemoryError traceback
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Workaround ctypes and SELinux incompatibility
cobbler-ctypes-workaround.patch (text/plain), 9.87 KB, created by
Toshio Ernie Kuratomi
on 2012-10-23 17:30:33 UTC
(
hide
)
Description:
Workaround ctypes and SELinux incompatibility
Filename:
MIME Type:
Creator:
Toshio Ernie Kuratomi
Created:
2012-10-23 17:30:33 UTC
Size:
9.87 KB
patch
obsolete
>diff -uNr cobbler-2.4.0.bak/cobbler/modules/_authn_pam/__init__.py cobbler-2.4.0/cobbler/modules/_authn_pam/__init__.py >--- cobbler-2.4.0.bak/cobbler/modules/_authn_pam/__init__.py 1969-12-31 16:00:00.000000000 -0800 >+++ cobbler-2.4.0/cobbler/modules/_authn_pam/__init__.py 2012-10-11 16:13:17.000000000 -0700 >@@ -0,0 +1,169 @@ >+""" >+Authentication module that uses /etc/cobbler/auth.conf >+Choice of authentication module is in /etc/cobbler/modules.conf >+ >+Copyright 2007-2009, Red Hat, Inc and Others >+Michael DeHaan <michael.dehaan AT gmail> >+ >+This program 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 2 of the License, or >+(at your option) any later version. >+ >+This program 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 this program; if not, write to the Free Software >+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA >+02110-1301 USA >+ >+PAM python code based on the pam_python code created by Chris AtLee: >+http://atlee.ca/software/pam/ >+ >+------------------------------------------------ >+pam_python (c) 2007 Chris AtLee <chris@atlee.ca> >+Licensed under the MIT license: >+http://www.opensource.org/licenses/mit-license.php >+ >+PAM module for python >+ >+Provides an authenticate function that will allow the caller to authenticate >+a user against the Pluggable Authentication Modules (PAM) on the system. >+ >+Implemented using ctypes, so no compilation is necessary. >+""" >+ >+import distutils.sysconfig >+import ConfigParser >+import sys >+import os >+from utils import _ >+import traceback >+ >+plib = distutils.sysconfig.get_python_lib() >+mod_path="%s/cobbler" % plib >+sys.path.insert(0, mod_path) >+ >+import cexceptions >+import utils >+ >+from ctypes import CDLL, POINTER, Structure, CFUNCTYPE, cast, pointer, sizeof >+from ctypes import c_void_p, c_uint, c_char_p, c_char, c_int >+from ctypes.util import find_library >+ >+LIBPAM = CDLL(find_library("pam")) >+LIBC = CDLL(find_library("c")) >+ >+CALLOC = LIBC.calloc >+CALLOC.restype = c_void_p >+CALLOC.argtypes = [c_uint, c_uint] >+ >+STRDUP = LIBC.strdup >+STRDUP.argstypes = [c_char_p] >+STRDUP.restype = POINTER(c_char) # NOT c_char_p !!!! >+ >+# Various constants >+PAM_PROMPT_ECHO_OFF = 1 >+PAM_PROMPT_ECHO_ON = 2 >+PAM_ERROR_MSG = 3 >+PAM_TEXT_INFO = 4 >+ >+def register(): >+ """ >+ The mandatory cobbler module registration hook. >+ """ >+ return "authn" >+ >+class PamHandle(Structure): >+ """wrapper class for pam_handle_t""" >+ _fields_ = [ >+ ("handle", c_void_p) >+ ] >+ >+ def __init__(self): >+ Structure.__init__(self) >+ self.handle = 0 >+ >+class PamMessage(Structure): >+ """wrapper class for pam_message structure""" >+ _fields_ = [ >+ ("msg_style", c_int), >+ ("msg", c_char_p), >+ ] >+ >+ def __repr__(self): >+ return "<PamMessage %i '%s'>" % (self.msg_style, self.msg) >+ >+class PamResponse(Structure): >+ """wrapper class for pam_response structure""" >+ _fields_ = [ >+ ("resp", c_char_p), >+ ("resp_retcode", c_int), >+ ] >+ >+ def __repr__(self): >+ return "<PamResponse %i '%s'>" % (self.resp_retcode, self.resp) >+ >+CONV_FUNC = CFUNCTYPE(c_int, >+ c_int, POINTER(POINTER(PamMessage)), >+ POINTER(POINTER(PamResponse)), c_void_p) >+ >+class PamConv(Structure): >+ """wrapper class for pam_conv structure""" >+ _fields_ = [ >+ ("conv", CONV_FUNC), >+ ("appdata_ptr", c_void_p) >+ ] >+ >+PAM_START = LIBPAM.pam_start >+PAM_START.restype = c_int >+PAM_START.argtypes = [c_char_p, c_char_p, POINTER(PamConv), >+ POINTER(PamHandle)] >+ >+PAM_AUTHENTICATE = LIBPAM.pam_authenticate >+PAM_AUTHENTICATE.restype = c_int >+PAM_AUTHENTICATE.argtypes = [PamHandle, c_int] >+ >+def authenticate(api_handle, username, password): >+ """ >+ Returns True if the given username and password authenticate for the >+ given service. Returns False otherwise >+ """ >+ >+ @CONV_FUNC >+ def my_conv(n_messages, messages, p_response, app_data): >+ """Simple conversation function that responds to any >+ prompt where the echo is off with the supplied password""" >+ # Create an array of n_messages response objects >+ addr = CALLOC(n_messages, sizeof(PamResponse)) >+ p_response[0] = cast(addr, POINTER(PamResponse)) >+ for i in range(n_messages): >+ if messages[i].contents.msg_style == PAM_PROMPT_ECHO_OFF: >+ pw_copy = STRDUP(str(password)) >+ p_response.contents[i].resp = cast(pw_copy, c_char_p) >+ p_response.contents[i].resp_retcode = 0 >+ return 0 >+ >+ try: >+ service = api_handle.settings().authn_pam_service >+ except: >+ service = 'login' >+ >+ api_handle.logger.debug("authn_pam: PAM service is %s" % service) >+ >+ handle = PamHandle() >+ conv = PamConv(my_conv, 0) >+ retval = PAM_START(service, username, pointer(conv), pointer(handle)) >+ >+ if retval != 0: >+ # TODO: This is not an authentication error, something >+ # has gone wrong starting up PAM >+ api_handle.logger.error("authn_pam: error initializing PAM library") >+ return False >+ >+ retval = PAM_AUTHENTICATE(handle, 0) >+ return retval == 0 >+ >diff -uNr cobbler-2.4.0.bak/cobbler/modules/authn_pam.py cobbler-2.4.0/cobbler/modules/authn_pam.py >--- cobbler-2.4.0.bak/cobbler/modules/authn_pam.py 2012-10-11 16:13:17.000000000 -0700 >+++ cobbler-2.4.0/cobbler/modules/authn_pam.py 2012-10-23 09:57:05.428941168 -0700 >@@ -37,133 +37,18 @@ > """ > > import distutils.sysconfig >-import ConfigParser > import sys >-import os >-from utils import _ >-import traceback > > plib = distutils.sysconfig.get_python_lib() > mod_path="%s/cobbler" % plib > sys.path.insert(0, mod_path) > >-import cexceptions >-import utils >- >-from ctypes import CDLL, POINTER, Structure, CFUNCTYPE, cast, pointer, sizeof >-from ctypes import c_void_p, c_uint, c_char_p, c_char, c_int >-from ctypes.util import find_library >- >-LIBPAM = CDLL(find_library("pam")) >-LIBC = CDLL(find_library("c")) >- >-CALLOC = LIBC.calloc >-CALLOC.restype = c_void_p >-CALLOC.argtypes = [c_uint, c_uint] >- >-STRDUP = LIBC.strdup >-STRDUP.argstypes = [c_char_p] >-STRDUP.restype = POINTER(c_char) # NOT c_char_p !!!! >- >-# Various constants >-PAM_PROMPT_ECHO_OFF = 1 >-PAM_PROMPT_ECHO_ON = 2 >-PAM_ERROR_MSG = 3 >-PAM_TEXT_INFO = 4 >- >-def register(): >- """ >- The mandatory cobbler module registration hook. >- """ >- return "authn" >- >-class PamHandle(Structure): >- """wrapper class for pam_handle_t""" >- _fields_ = [ >- ("handle", c_void_p) >- ] >- >- def __init__(self): >- Structure.__init__(self) >- self.handle = 0 >- >-class PamMessage(Structure): >- """wrapper class for pam_message structure""" >- _fields_ = [ >- ("msg_style", c_int), >- ("msg", c_char_p), >- ] >- >- def __repr__(self): >- return "<PamMessage %i '%s'>" % (self.msg_style, self.msg) >- >-class PamResponse(Structure): >- """wrapper class for pam_response structure""" >- _fields_ = [ >- ("resp", c_char_p), >- ("resp_retcode", c_int), >- ] >- >- def __repr__(self): >- return "<PamResponse %i '%s'>" % (self.resp_retcode, self.resp) >- >-CONV_FUNC = CFUNCTYPE(c_int, >- c_int, POINTER(POINTER(PamMessage)), >- POINTER(POINTER(PamResponse)), c_void_p) >- >-class PamConv(Structure): >- """wrapper class for pam_conv structure""" >- _fields_ = [ >- ("conv", CONV_FUNC), >- ("appdata_ptr", c_void_p) >- ] >- >-PAM_START = LIBPAM.pam_start >-PAM_START.restype = c_int >-PAM_START.argtypes = [c_char_p, c_char_p, POINTER(PamConv), >- POINTER(PamHandle)] >- >-PAM_AUTHENTICATE = LIBPAM.pam_authenticate >-PAM_AUTHENTICATE.restype = c_int >-PAM_AUTHENTICATE.argtypes = [PamHandle, c_int] >- >-def authenticate(api_handle, username, password): >- """ >- Returns True if the given username and password authenticate for the >- given service. Returns False otherwise >- """ >- >- @CONV_FUNC >- def my_conv(n_messages, messages, p_response, app_data): >- """Simple conversation function that responds to any >- prompt where the echo is off with the supplied password""" >- # Create an array of n_messages response objects >- addr = CALLOC(n_messages, sizeof(PamResponse)) >- p_response[0] = cast(addr, POINTER(PamResponse)) >- for i in range(n_messages): >- if messages[i].contents.msg_style == PAM_PROMPT_ECHO_OFF: >- pw_copy = STRDUP(str(password)) >- p_response.contents[i].resp = cast(pw_copy, c_char_p) >- p_response.contents[i].resp_retcode = 0 >- return 0 >- >- try: >- service = api_handle.settings().authn_pam_service >- except: >- service = 'login' >- >- api_handle.logger.debug("authn_pam: PAM service is %s" % service) >- >- handle = PamHandle() >- conv = PamConv(my_conv, 0) >- retval = PAM_START(service, username, pointer(conv), pointer(handle)) >- >- if retval != 0: >- # TODO: This is not an authentication error, something >- # has gone wrong starting up PAM >- api_handle.logger.error("authn_pam: error initializing PAM library") >- return False >- >- retval = PAM_AUTHENTICATE(handle, 0) >- return retval == 0 >- >+try: >+ import ctypes >+except MemoryError: >+ ### FIXME: use the logger to write this error message >+ sys.stderr.write('Error: authn_pam will be disabled because ctypes is unusable.\n') >+ sys.stderr.write('Error: Please read this manual page if you need authn_pam functionality:\n') >+ sys.stderr.write('Error: http://cobbler.github.com/manuals/2.2.3/5/2_-_SELinux.html\n') >+else: >+ from _authn_pam import *
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 838898
: 632243