apparmor-3.0.4/ 0000775 0001750 0001750 00000000000 14201060045 011121 5 ustar jj jj apparmor-3.0.4/changehat/ 0000775 0001750 0001750 00000000000 14201060045 013043 5 ustar jj jj apparmor-3.0.4/changehat/tomcat_apparmor/ 0000775 0001750 0001750 00000000000 14201060045 016233 5 ustar jj jj apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/ 0000775 0001750 0001750 00000000000 14201060045 020172 5 ustar jj jj apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/Manifest 0000664 0001750 0001750 00000000033 14201060045 021657 0 ustar jj jj Main-Class: ChangeHatValve
apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/build.xml 0000664 0001750 0001750 00000007017 14201060045 022020 0 ustar jj jj
apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/Makefile 0000664 0001750 0001750 00000002220 14201060045 021626 0 ustar jj jj # ----------------------------------------------------------------------
# Copyright (c) 1999, 2004, 2005, 2006 NOVELL (All rights reserved)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# 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, contact Novell, Inc.
# ----------------------------------------------------------------------
NAME = tomcat_apparmor
all:
COMMONDIR=../../../common/
include $(COMMONDIR)/Make.rules
LIB = lib
CATALINA_HOME = /usr/share/tomcat55
all:
ant -Dcatalina_home=${CATALINA_HOME} -Dtarget=1.5 jar jni_so
clean:
ant clean
install:
ant -Dversion=$(VERSION) -Drelease=$(MAN_RELEASE) -Dcatalina_home=${CATALINA_HOME} -Dinstall_lib=${LIB} install_jar install_jni
apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/README.tomcat_apparmor 0000664 0001750 0001750 00000014725 14201060045 024252 0 ustar jj jj # ------------------------------------------------------------------
#
# Copyright (C) 2002-2006 Novell/SUSE
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# ------------------------------------------------------------------
----------------------
1. Overview
2. Requirements
3. Compiling the code
4. Installation
5. Generating a basic Tomcat profile
6. Implementation Notes
7. Profile Generation Tools and change_hat
8. Feedback/Resources
-----------------------
1. Overview
--------
This package provides an implementation of a Tomcat 5.0 Valve that calls out
to the change_hat(2) function provided by libapparmor to allow a process to
change its security context. Any feedback is greatly appreciated.
2. Requirements
------------
AppArmor version 1.2 or later
Tomcat version 5.0.X
JDK 1.4.2 or later
3. Compiling the Code
-----------------
From the top level directory execute:
ant jar jni_so
This will create a jar file and a shared library (for the JNI interface to the
libapparmor library) and place the jar file under dist/ and the shared library
under src/jni_src.
4. Installation
------------
- Copy the jar file to $TOMCAT_HOME/server/lib:
[SLES10 example]
cp dist/changeHatValve.jar /usr/share/tomcat5/server/lib
- Copy the shared library to somehere in your library search path:
cp dist/libJNIChangeHat.so /usr/lib
[Note: you must ensure that the target directory is passed to tomcat via the
java.library.path propert. This can be accomplished by setting the JAVA_OPTS
enviroment variable, export JAVA_OPTS=-Djava.library.path, or set via the
env variable LD_LIBRARY_PATH to include this directory so that tomcat can
find this library at startup]
- Configure the Tomcat server to use ChangeHatValve:
Place the configuration directive below in your server.xml file. The valve
definition should be the initial configuration option declared in the
top-level container in the container hierarchy.
[Note: The mediationType attribute may be set to ServletPath or URI depending
on the granularity of containers that you wish to create. URI will
prompt the user to create containers for every URI it processes. This
is not recommended for most deployment scenarios and so the default
"ServletPath" should be used. This maps to containers identified by
the ServletPath header defined in the HttpRequest.]
- Defining a default and required hat for the tomcat profile
Edit the file /etc/apparmor/logprof.conf and add the following line to the
section [required_hats]:
^.+/catalina.sh$ = DEFAULT
Edit the file /etc/apparmor/logprof.conf and add the following line to the
section [default_hat]:
^.+/catalina.sh$ = DEFAULT
5. Generating a basic Tomcat profile
-------------------------------
Once the installation steps above have been started you are ready to begin
creating a profile for your application. The profile creation tool genprof will
guide you through generating a profile and its support for change_hat will
prompt you create discrete hats as requested byt the changeHatValve during
tomcat execution.
1. Create a basic profile for the tomcat server.
- Run the command "genprof PATH_TO_CATALINA.SH"
- In a seperate window start tomcat and then stop tomcat
- In the genprof window press "S" to scan for events
- Answer the questions about the initial profile for tomcat
2. Extending the profile to include containers for your web-app
- Stop the tomcat server
- Deploy your WAR file or equivalent files under the container.
- execute "genprof PATH_TO_CATALINA.SH"
- In a seperate window start tomcat and then exercise your web application
- In the genprof window press "S" to scan for events
During the prompting you will be asked questions similar to:
-----------------------------------------------
Profile: /usr/share/tomcat5/bin/catalina.sh
Default Hat: DEFAULT
Requested Hat: /servlet/CookieExample
(A)dd Requested Hat / (U)se Default Hat / (D)eny / Abo(r)t / (F)inish
------------------------------------------------
This example shows the tomcat valve for changehat attempting to change to
the hat "/servlet/CookieExample". You can choose to create this hat, and
subsequently fill it with resources, use the Default hat, named "DEFAULT"
and is the default hat for request processing.
6. Implementation Notes
--------------------
- Selecting the hat during request processing
This implementation follows the following pattern to decide what hat to execute in for an incoming request:
Try #1: Request data (URI or ServletInfo)
if #1 fails (because the hat does not exist) then try #2
Try #2: DEFAULT - this is the default hat for request processing
if #2 fails (because of any error) then..
Error: report that change_hat calls failed and remain in current security context.
- Java 1.4.2 Notes
This library uses java.security.SecureRandom to generate random numbers used as cookies in
the change_hat(2) interface. This class on java version 1.4.2 uses /dev/random which is a
blocking call and can adversely effect performance. Java can be configured to use
/dev/urandom instead. For details:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4705093
7. Profile Tools and change_hat
----------------------------
When using the profile generation tool, genprof, you will be prompted to add a
new hat when you exercise your program and requests are processed by the
changeHatValve. You can choose to Add the hat or use the Default hat.
If you choose to add the requested hat: genprof will create the hat and then
all subsequent resource requests will be mediated in this hew hat (or security
context).
If you choose to use the default hat: genprof will mediate all resource
requests in the default hat for the duration of processing this request.
When the request processng is complete the valve will change_hat back to the
parent context.
8. Feedback/Resources
-----------------
To provide feedback or ask questions please contact the
apparmor-dev@forge.novell.com mail list. This is the development list for the
AppArmor team.
apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/src/ 0000775 0001750 0001750 00000000000 14201060045 020761 5 ustar jj jj apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/src/jni_src/ 0000775 0001750 0001750 00000000000 14201060045 022410 5 ustar jj jj apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/src/jni_src/JNIChangeHat.c 0000664 0001750 0001750 00000002703 14201060045 024741 0 ustar jj jj /*
------------------------------------------------------------------
Copyright (C) 2002-2005 Novell/SUSE
This program is free software; you can redistribute it and/or
modify it under the terms of version 2 of the GNU General Public
License published by the Free Software Foundation.
------------------------------------------------------------------
*/
#include "jni.h"
#include
#include
#include "com_novell_apparmor_JNIChangeHat.h"
/* c intermediate lib call for Java -> JNI -> c library execution of the change_hat call */
JNIEXPORT jint Java_com_novell_apparmor_JNIChangeHat_changehat_1in
(JNIEnv *env, jobject obj, jstring hatnameUTF, jint token)
{
int len;
jint result = 0;
if ( hatnameUTF == NULL ) {
return ( EINVAL );
}
len = (*env)->GetStringLength(env, hatnameUTF);
if ( len > 0 ) {
if ( len > 128 ) {
len = 128;
}
char hatname[128];
(*env)->GetStringUTFRegion(env, hatnameUTF, 0, len, hatname);
result = (jint) change_hat(hatname, (unsigned int) token);
if ( result ) {
return errno;
} else {
return result;
}
}
return (jint) result;
}
JNIEXPORT jint JNICALL Java_com_novell_apparmor_JNIChangeHat_changehat_1out
(JNIEnv *env, jobject obj, jint token)
{
jint result = 0;
result = (jint) change_hat(NULL, (unsigned int) token);
if ( result ) {
return errno;
} else {
return result;
}
}
apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/src/jni_src/Makefile 0000664 0001750 0001750 00000002637 14201060045 024060 0 ustar jj jj TOP = ../..
CLASSPATH = ${TOP}/build
LIB = lib/
LIBDIR = /usr/${LIB}
INCLUDE = ${LIBDIR}/jvm/java/include
CFLAGS = -g -O2 -Wall -Wstrict-prototypes -Wl,-soname,$@.${SO_VERS} -pipe -fpic -D_REENTRANT
INCLUDES = -I$(INCLUDE) -I$(INCLUDE)/linux -I$(TOP)/../../../libraries/libapparmor/src/
CLASSFILE = ${CLASSPATH}/com/novell/apparmor/${JAVA_CLASSNAME}.class
DESTDIR = ${TOP}/dist
SO_VERS = 1
JAVA_CLASSNAME = JNIChangeHat
TARGET = lib${JAVA_CLASSNAME}
all: ${TARGET}.so
clean:
rm -f *.so *.so.${SO_VERS} ${JAVA_CLASSNAME}.java com_novell_apparmor_${JAVA_CLASSNAME}.h
${JAVA_CLASSNAME}.java com_novell_apparmor_${JAVA_CLASSNAME}.h: ${CLASSFILE}
javah -jni -classpath ${CLASSPATH} com.novell.apparmor.${JAVA_CLASSNAME}
${TARGET}.so: ${JAVA_CLASSNAME}.c ${JAVA_CLASSNAME}.java com_novell_apparmor_${JAVA_CLASSNAME}.h
gcc ${INCLUDES} ${CFLAGS} -shared -o ${TARGET}.so ${JAVA_CLASSNAME}.c -L$(TOP)/../../../libraries/libapparmor/src/.libs -lapparmor
install: ${TARGET}.so
install -d $(DESTDIR)/${LIB} $(DESTDIR)${LIBDIR}
mv -f $(TARGET).so $(TARGET)-$(VERSION)-$(RELEASE).so.$(SO_VERS)
install -m 755 $(TARGET)-$(VERSION)-$(RELEASE).so.$(SO_VERS) ${DESTDIR}/${LIB}
ln -sf /${LIB}/$(TARGET)-$(VERSION)-$(RELEASE).so.$(SO_VERS) ${DESTDIR}/${LIB}/$(TARGET).so.$(SO_VERS)
ln -sf /${LIB}/$(TARGET).so.$(SO_VERS) ${DESTDIR}${LIBDIR}/$(TARGET).so
apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/src/com/ 0000775 0001750 0001750 00000000000 14201060045 021537 5 ustar jj jj apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/src/com/novell/ 0000775 0001750 0001750 00000000000 14201060045 023036 5 ustar jj jj apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/src/com/novell/apparmor/ 0000775 0001750 0001750 00000000000 14201060045 024657 5 ustar jj jj apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/src/com/novell/apparmor/catalina/ 0000775 0001750 0001750 00000000000 14201060045 026433 5 ustar jj jj apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/src/com/novell/apparmor/catalina/valves/ 0000775 0001750 0001750 00000000000 14201060045 027733 5 ustar jj jj ././@LongLink 0000644 0000000 0000000 00000000160 00000000000 011600 L ustar root root apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/src/com/novell/apparmor/catalina/valves/ChangeHatValve.java apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/src/com/novell/apparmor/catalina/valves/ChangeHa0000664 0001750 0001750 00000014537 14201060045 031326 0 ustar jj jj /* ------------------------------------------------------------------
*
* Copyright (C) 2002-2007 Novell/SUSE
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License published by the Free Software Foundation.
*
* ------------------------------------------------------------------ */
package com.novell.apparmor.catalina.valves;
import com.novell.apparmor.JNIChangeHat;
import java.io.IOException;
import javax.servlet.ServletException;
import org.apache.catalina.Container;
import org.apache.catalina.valves.ValveBase;
import java.security.SecureRandom;
public final class ChangeHatValve extends ValveBase {
// JNI interface class for AppArmor change_hat
private static JNIChangeHat changehat_wrapper = new JNIChangeHat();
private static SecureRandom randomNumberGenerator = null;
private static String DEFAULT_HAT = "DEFAULT";
private static int SERVLET_PATH_MEDIATION = 0;
private static int URI_MEDIATION = 1;
private int mediationType = ChangeHatValve.SERVLET_PATH_MEDIATION;
/*
*
* Property setter called during the parsing of the server.xml.
* If the mediationType is an attribute of the
* Valve definition for
* com.novell.apparmor.catalina.valves.ChangeHatValve
* then this setter will be called to set the value for this property.
*
* @param type URI|ServletPath
*
* Controls what granularity of security confinement when used with
* AppArmor change_hat(2). Either based upon getServletPath()
* or getRequestURI() called against on the request.
*
*/
public void setMediationType( String type ) {
if ( type.equalsIgnoreCase("URI") ) {
this.mediationType = ChangeHatValve.URI_MEDIATION;
} else if ( type.equalsIgnoreCase("servletPath") ) {
this.mediationType = ChangeHatValve.SERVLET_PATH_MEDIATION;
}
}
/*
*
* Return an int value representing the currently configured
* mediationType for this instance.
*
*/
public int getMediationType() {
return this.mediationType;
}
/*
*
* Return an instance of SecureRandom creating one if necessary
*
*/
SecureRandom getRndGen() {
if ( ChangeHatValve.randomNumberGenerator == null) {
ChangeHatValve.randomNumberGenerator = new java.security.SecureRandom();
}
return ChangeHatValve.randomNumberGenerator;
}
/*
*
* Call to return a random cookie from the SecureRandom PRNG
*
*/
int getCookie() {
SecureRandom rnd = getRndGen();
if ( rnd == null ) {
this.getContainer().getLogger().error(
"[APPARMOR] can't initialize SecureRandom for cookie" +
" generation for change_hat() call.");
return 0;
}
return rnd.nextInt();
}
/*
*
* Call out to AppArmor change_hat(2) to change the security
* context for the processing of the request by subsequent valves.
* Returns to the current security context when processing is complete.
* The security context that is chosen is govern by the
* mediationType property - which can be set in the
* server.xml file.
*
* @param request Request being processed
* @param response Response being processed
* @param context The valve context used to invoke the next valve
* in the current processing pipeline
*
* @exception IOException if an input/output error has occurred
* @exception ServletException if a servlet error has occurred
*
*/
public void invoke( org.apache.catalina.connector.Request request,
org.apache.catalina.connector.Response response )
throws IOException, ServletException {
Container container = this.getContainer();
int cookie, result;
boolean inSubHat = false;
container.getLogger().debug(this.getClass().toString() +
"[APPARMOR] Request received [" + request.getInfo()
+ "]");
String hatname = ChangeHatValve.DEFAULT_HAT;;
if ( getMediationType() == ChangeHatValve.SERVLET_PATH_MEDIATION ) {
hatname = request.getServletPath();
} else if ( getMediationType() == ChangeHatValve.URI_MEDIATION ) {
hatname = request.getRequestURI();
}
/*
* Select the AppArmor container for this request:
*
* 1. try hat name from either URI or ServletPath
* (based on configuration)
*
* 2. try hat name of the defined DEFAULT_HAT
*
* 3. run in the current AppArmor context
*/
cookie = getCookie();
if ( hatname == null || "".equals(hatname) ) {
hatname = ChangeHatValve.DEFAULT_HAT;
}
container.getLogger().debug("[APPARMOR] ChangeHat to [" + hatname
+ "] cookie [" + cookie + "]");
result = changehat_wrapper.changehat_in(hatname, cookie);
if ( result == JNIChangeHat.EPERM ) {
container.getLogger().error("[APPARMOR] change_hat valve " +
"configured but Tomcat process is not confined by an " +
"AppArmor profile.");
getNext().invoke(request, response);
} else {
if ( result == JNIChangeHat.EACCES ) {
changehat_wrapper.changehat_out(cookie);
result = changehat_wrapper.changehat_in(ChangeHatValve.DEFAULT_HAT,
cookie);
if ( result != 0 ) {
changehat_wrapper.changehat_out(cookie);
container.getLogger().error("[APPARMOR] ChangeHat to [" + hatname
+ "] failed. Running in parent context.");
} else {
inSubHat = true;
}
} else if ( result != 0 ) {
changehat_wrapper.changehat_out(cookie);
container.getLogger().error("[APPARMOR] ChangeHat to [" + hatname
+ "] failed. Running in parent context.");
} else {
inSubHat = true;
}
getNext().invoke(request, response);
if ( inSubHat ) changehat_wrapper.changehat_out(cookie);
}
}
}
apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_5/src/com/novell/apparmor/JNIChangeHat.java 0000664 0001750 0001750 00000002010 14201060045 027676 0 ustar jj jj /* ------------------------------------------------------------------
*
* Copyright (C) 2002-2005 Novell/SUSE
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License published by the Free Software Foundation.
*
* ------------------------------------------------------------------ */
package com.novell.apparmor;
import java.nio.*;
/**
*
* JNI interface to AppArmor change_hat(2) call
*
**/
public class JNIChangeHat
{
public static int EPERM = 1;
public static int ENOMEM = 12;
public static int EACCES = 13;
public static int EFAULT = 14;
// Native 'c' function delcaration
public native int changehat_in(String subdomain, int magic_token);
// Native 'c' function delcaration
public native int changehat_out(int magic_token);
static
{
// The runtime system executes a class's static initializer
// when it loads the class.
System.loadLibrary("JNIChangeHat");
}
}
apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/ 0000775 0001750 0001750 00000000000 14201060045 020165 5 ustar jj jj apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/Manifest 0000664 0001750 0001750 00000000033 14201060045 021652 0 ustar jj jj Main-Class: ChangeHatValve
apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/build.xml 0000664 0001750 0001750 00000006762 14201060045 022021 0 ustar jj jj
apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/Makefile 0000664 0001750 0001750 00000002215 14201060045 021625 0 ustar jj jj # ----------------------------------------------------------------------
# Copyright (c) 1999, 2004, 2005, 2006 NOVELL (All rights reserved)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# 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, contact Novell, Inc.
# ----------------------------------------------------------------------
NAME = tomcat_apparmor
all:
COMMONDIR=../../../common/
include $(COMMONDIR)/Make.rules
LIB = lib
CATALINA_HOME = /usr/share/tomcat5
# By default build 1.4 bytecode
all:
ant -Dtarget=1.4 jar jni_so
clean:
ant clean
install:
ant -Dversion=$(VERSION) -Drelease=$(MAN_RELEASE) -Dcatalina_home=${CATALINA_HOME} -Dinstall_lib=${LIB} install_jar install_jni
apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/README.tomcat_apparmor 0000664 0001750 0001750 00000014725 14201060045 024245 0 ustar jj jj # ------------------------------------------------------------------
#
# Copyright (C) 2002-2006 Novell/SUSE
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# ------------------------------------------------------------------
----------------------
1. Overview
2. Requirements
3. Compiling the code
4. Installation
5. Generating a basic Tomcat profile
6. Implementation Notes
7. Profile Generation Tools and change_hat
8. Feedback/Resources
-----------------------
1. Overview
--------
This package provides an implementation of a Tomcat 5.0 Valve that calls out
to the change_hat(2) function provided by libapparmor to allow a process to
change its security context. Any feedback is greatly appreciated.
2. Requirements
------------
AppArmor version 1.2 or later
Tomcat version 5.0.X
JDK 1.4.2 or later
3. Compiling the Code
-----------------
From the top level directory execute:
ant jar jni_so
This will create a jar file and a shared library (for the JNI interface to the
libapparmor library) and place the jar file under dist/ and the shared library
under src/jni_src.
4. Installation
------------
- Copy the jar file to $TOMCAT_HOME/server/lib:
[SLES10 example]
cp dist/changeHatValve.jar /usr/share/tomcat5/server/lib
- Copy the shared library to somehere in your library search path:
cp dist/libJNIChangeHat.so /usr/lib
[Note: you must ensure that the target directory is passed to tomcat via the
java.library.path propert. This can be accomplished by setting the JAVA_OPTS
enviroment variable, export JAVA_OPTS=-Djava.library.path, or set via the
env variable LD_LIBRARY_PATH to include this directory so that tomcat can
find this library at startup]
- Configure the Tomcat server to use ChangeHatValve:
Place the configuration directive below in your server.xml file. The valve
definition should be the initial configuration option declared in the
top-level container in the container hierarchy.
[Note: The mediationType attribute may be set to ServletPath or URI depending
on the granularity of containers that you wish to create. URI will
prompt the user to create containers for every URI it processes. This
is not recommended for most deployment scenarios and so the default
"ServletPath" should be used. This maps to containers identified by
the ServletPath header defined in the HttpRequest.]
- Defining a default and required hat for the tomcat profile
Edit the file /etc/apparmor/logprof.conf and add the following line to the
section [required_hats]:
^.+/catalina.sh$ = DEFAULT
Edit the file /etc/apparmor/logprof.conf and add the following line to the
section [default_hat]:
^.+/catalina.sh$ = DEFAULT
5. Generating a basic Tomcat profile
-------------------------------
Once the installation steps above have been started you are ready to begin
creating a profile for your application. The profile creation tool genprof will
guide you through generating a profile and its support for change_hat will
prompt you create discrete hats as requested byt the changeHatValve during
tomcat execution.
1. Create a basic profile for the tomcat server.
- Run the command "genprof PATH_TO_CATALINA.SH"
- In a seperate window start tomcat and then stop tomcat
- In the genprof window press "S" to scan for events
- Answer the questions about the initial profile for tomcat
2. Extending the profile to include containers for your web-app
- Stop the tomcat server
- Deploy your WAR file or equivalent files under the container.
- execute "genprof PATH_TO_CATALINA.SH"
- In a seperate window start tomcat and then exercise your web application
- In the genprof window press "S" to scan for events
During the prompting you will be asked questions similar to:
-----------------------------------------------
Profile: /usr/share/tomcat5/bin/catalina.sh
Default Hat: DEFAULT
Requested Hat: /servlet/CookieExample
(A)dd Requested Hat / (U)se Default Hat / (D)eny / Abo(r)t / (F)inish
------------------------------------------------
This example shows the tomcat valve for changehat attempting to change to
the hat "/servlet/CookieExample". You can choose to create this hat, and
subsequently fill it with resources, use the Default hat, named "DEFAULT"
and is the default hat for request processing.
6. Implementation Notes
--------------------
- Selecting the hat during request processing
This implementation follows the following pattern to decide what hat to execute in for an incoming request:
Try #1: Request data (URI or ServletInfo)
if #1 fails (because the hat does not exist) then try #2
Try #2: DEFAULT - this is the default hat for request processing
if #2 fails (because of any error) then..
Error: report that change_hat calls failed and remain in current security context.
- Java 1.4.2 Notes
This library uses java.security.SecureRandom to generate random numbers used as cookies in
the change_hat(2) interface. This class on java version 1.4.2 uses /dev/random which is a
blocking call and can adversely effect performance. Java can be configured to use
/dev/urandom instead. For details:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4705093
7. Profile Tools and change_hat
----------------------------
When using the profile generation tool, genprof, you will be prompted to add a
new hat when you exercise your program and requests are processed by the
changeHatValve. You can choose to Add the hat or use the Default hat.
If you choose to add the requested hat: genprof will create the hat and then
all subsequent resource requests will be mediated in this hew hat (or security
context).
If you choose to use the default hat: genprof will mediate all resource
requests in the default hat for the duration of processing this request.
When the request processng is complete the valve will change_hat back to the
parent context.
8. Feedback/Resources
-----------------
To provide feedback or ask questions please contact the
apparmor-dev@forge.novell.com mail list. This is the development list for the
AppArmor team.
apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/src/ 0000775 0001750 0001750 00000000000 14201060045 020754 5 ustar jj jj apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/src/jni_src/ 0000775 0001750 0001750 00000000000 14201060045 022403 5 ustar jj jj apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/src/jni_src/JNIChangeHat.c 0000664 0001750 0001750 00000002703 14201060045 024734 0 ustar jj jj /*
------------------------------------------------------------------
Copyright (C) 2002-2005 Novell/SUSE
This program is free software; you can redistribute it and/or
modify it under the terms of version 2 of the GNU General Public
License published by the Free Software Foundation.
------------------------------------------------------------------
*/
#include "jni.h"
#include
#include
#include "com_novell_apparmor_JNIChangeHat.h"
/* c intermediate lib call for Java -> JNI -> c library execution of the change_hat call */
JNIEXPORT jint Java_com_novell_apparmor_JNIChangeHat_changehat_1in
(JNIEnv *env, jobject obj, jstring hatnameUTF, jint token)
{
int len;
jint result = 0;
if ( hatnameUTF == NULL ) {
return ( EINVAL );
}
len = (*env)->GetStringLength(env, hatnameUTF);
if ( len > 0 ) {
if ( len > 128 ) {
len = 128;
}
char hatname[128];
(*env)->GetStringUTFRegion(env, hatnameUTF, 0, len, hatname);
result = (jint) change_hat(hatname, (unsigned int) token);
if ( result ) {
return errno;
} else {
return result;
}
}
return (jint) result;
}
JNIEXPORT jint JNICALL Java_com_novell_apparmor_JNIChangeHat_changehat_1out
(JNIEnv *env, jobject obj, jint token)
{
jint result = 0;
result = (jint) change_hat(NULL, (unsigned int) token);
if ( result ) {
return errno;
} else {
return result;
}
}
apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/src/jni_src/Makefile 0000664 0001750 0001750 00000002367 14201060045 024053 0 ustar jj jj INCLUDE=/usr/lib/jvm/java/include
TOP=../..
CLASSPATH=${TOP}/build
CFLAGS=-g -O2 -Wall -Wstrict-prototypes -Wl,-soname,$@.${SO_VERS} -pipe -fpic -D_REENTRANT
INCLUDES=-I$(INCLUDE) -I$(INCLUDE)/linux
CLASSFILE=${CLASSPATH}/com/novell/apparmor/${JAVA_CLASSNAME}.class
DESTDIR=${TOP}/dist
SO_VERS = 1
LIB = lib/
LIBDIR = /usr/${LIB}
JAVA_CLASSNAME=JNIChangeHat
TARGET=lib${JAVA_CLASSNAME}
all: ${TARGET}.so
clean:
rm -f *.so *.so.${SO_VERS} ${JAVA_CLASSNAME}.java com_novell_apparmor_${JAVA_CLASSNAME}.h
${JAVA_CLASSNAME}.java com_novell_apparmor_${JAVA_CLASSNAME}.h: ${CLASSFILE}
javah -jni -classpath ${CLASSPATH} com.novell.apparmor.${JAVA_CLASSNAME}
${TARGET}.so: ${JAVA_CLASSNAME}.c ${JAVA_CLASSNAME}.java com_novell_apparmor_${JAVA_CLASSNAME}.h
gcc ${INCLUDES} ${CFLAGS} -shared -o ${TARGET}.so ${JAVA_CLASSNAME}.c -lapparmor
install: ${TARGET}.so
install -d $(DESTDIR)/${LIB} $(DESTDIR)${LIBDIR}
mv -f $(TARGET).so $(TARGET)-$(VERSION)-$(RELEASE).so.$(SO_VERS)
install -m 755 $(TARGET)-$(VERSION)-$(RELEASE).so.$(SO_VERS) ${DESTDIR}/${LIB}
ln -sf /${LIB}/$(TARGET)-$(VERSION)-$(RELEASE).so.$(SO_VERS) ${DESTDIR}/${LIB}/$(TARGET).so.$(SO_VERS)
ln -sf /${LIB}/$(TARGET).so.$(SO_VERS) ${DESTDIR}${LIBDIR}/$(TARGET).so
apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/src/com/ 0000775 0001750 0001750 00000000000 14201060045 021532 5 ustar jj jj apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/src/com/novell/ 0000775 0001750 0001750 00000000000 14201060045 023031 5 ustar jj jj apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/src/com/novell/apparmor/ 0000775 0001750 0001750 00000000000 14201060045 024652 5 ustar jj jj apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/src/com/novell/apparmor/catalina/ 0000775 0001750 0001750 00000000000 14201060045 026426 5 ustar jj jj apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/src/com/novell/apparmor/catalina/valves/ 0000775 0001750 0001750 00000000000 14201060045 027726 5 ustar jj jj ././@LongLink 0000644 0000000 0000000 00000000160 00000000000 011600 L ustar root root apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/src/com/novell/apparmor/catalina/valves/ChangeHatValve.java apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/src/com/novell/apparmor/catalina/valves/ChangeHa0000664 0001750 0001750 00000016422 14201060045 031314 0 ustar jj jj /* ------------------------------------------------------------------
*
* Copyright (C) 2002-2005 Novell/SUSE
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License published by the Free Software Foundation.
*
* ------------------------------------------------------------------ */
package com.novell.apparmor.catalina.valves;
import com.novell.apparmor.JNIChangeHat;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import org.apache.catalina.HttpRequest;
import org.apache.catalina.Container;
import org.apache.catalina.HttpResponse;
import org.apache.catalina.valves.ValveBase;
import java.security.SecureRandom;
public final class ChangeHatValve extends ValveBase {
// JNI interface class for AppArmor change_hat
private static JNIChangeHat changehat_wrapper = new JNIChangeHat();
private static SecureRandom randomNumberGenerator = null;
private static String DEFAULT_HAT = "DEFAULT";
private static int SERVLET_PATH_MEDIATION = 0;
private static int URI_MEDIATION = 1;
private int mediationType = ChangeHatValve.SERVLET_PATH_MEDIATION;
/*
*
* Property setter called during the parsing of the server.xml.
* If the mediationType is an attribute of the
* Valve definition for
* com.novell.apparmor.catalina.valves.ChangeHatValve
* then this setter will be called to set the value for this property.
*
* @param type URI|ServletPath
*
* Controls what granularity of security confinement when used with
* AppArmor change_hat(2). Either based upon getServletPath()
* or getRequestURI() called against on the request.
*
*/
public void setMediationType( String type ) {
if ( type.equalsIgnoreCase("URI") ) {
this.mediationType = ChangeHatValve.URI_MEDIATION;
} else if ( type.equalsIgnoreCase("servletPath") ) {
this.mediationType = ChangeHatValve.SERVLET_PATH_MEDIATION;
}
}
/*
*
* Return an int value representing the currently configured
* mediationType for this instance.
*
*/
int getMediationType() {
return this.mediationType;
}
/*
*
* Return an instance of SecureRandom creating one if necessary
*
*/
SecureRandom getRndGen() {
if ( ChangeHatValve.randomNumberGenerator == null) {
ChangeHatValve.randomNumberGenerator = new java.security.SecureRandom();
}
return ChangeHatValve.randomNumberGenerator;
}
/*
*
* Call to return a random cookie from the SecureRandom PRNG
*
*/
int getCookie() {
SecureRandom rnd = getRndGen();
if ( rnd == null ) {
this.getContainer().getLogger().log( "[APPARMOR] can't initialize SecureRandom for cookie generation for change_hat() call.", container.getLogger().ERROR);
return 0;
}
return rnd.nextInt();
}
/*
*
* Call out to AppArmor change_hat(2) to change the security
* context for the processing of the request by subsequent valves.
* Returns to the current security context when processing is complete.
* The security context that is chosen is govern by the
* mediationType property - which can be set in the
* server.xml file.
*
* @param request Request being processed
* @param response Response being processed
* @param context The valve context used to invoke the next valve
* in the current processing pipeline
*
* @exception IOException if an input/output error has occurred
* @exception ServletException if a servlet error has occurred
*
*/
public void invoke( org.apache.catalina.Request request,
org.apache.catalina.Response response,
org.apache.catalina.ValveContext context )
throws IOException, ServletException {
Container container = this.getContainer();
int cookie, result;
boolean inSubHat = false;
container.getLogger().log(this.getClass().toString() +
"[APPARMOR] Request received [" + request.getInfo()
+ "]", container.getLogger().DEBUG);
if ( !( request instanceof HttpRequest)
|| !(response instanceof HttpResponse) ) {
container.getLogger().log(this.getClass().toString()
+ "[APPARMOR] Non HttpRequest received. Not changing context. "
+ "[" + request.getInfo() + "]", container.getLogger().ERROR);
context.invokeNext(request, response);
return;
}
HttpRequest httpRequest = (HttpRequest) request;
HttpServletRequest servletRequest = (HttpServletRequest)
httpRequest.getRequest();
String hatname = ChangeHatValve.DEFAULT_HAT;;
if ( getMediationType() == ChangeHatValve.SERVLET_PATH_MEDIATION ) {
hatname = servletRequest.getServletPath();
} else if ( getMediationType() == ChangeHatValve.URI_MEDIATION ) {
hatname = servletRequest.getRequestURI();
}
/*
* Select the AppArmor container for this request:
*
* 1. try hat name from either URI or ServletPath
* (based on configuration)
*
* 2. try hat name of the defined DEFAULT_HAT
*
* 3. run in the current AppArmor context
*/
cookie = getCookie();
if ( hatname == null || "".equals(hatname) ) {
hatname = ChangeHatValve.DEFAULT_HAT;
}
container.getLogger().log("[APPARMOR] ChangeHat to [" + hatname
+ "] cookie [" + cookie + "]", container.getLogger().DEBUG);
result = changehat_wrapper.changehat_in(hatname, cookie);
if ( result == JNIChangeHat.EPERM ) {
container.getLogger().log("[APPARMOR] change_hat valve " +
"configured but Tomcat process is not confined by an " +
"AppArmor profile.", container.getLogger().ERROR);
context.invokeNext(request, response);
} else {
if ( result == JNIChangeHat.EACCES ) {
changehat_wrapper.changehat_out(cookie);
result = changehat_wrapper.changehat_in(ChangeHatValve.DEFAULT_HAT,
cookie);
if ( result != 0 ) {
changehat_wrapper.changehat_out(cookie);
container.getLogger().log("[APPARMOR] ChangeHat to [" + hatname
+ "] failed. Running in parent context.",
container.getLogger().ERROR);
} else {
inSubHat = true;
}
} else if ( result != 0 ) {
changehat_wrapper.changehat_out(cookie);
container.getLogger().log("[APPARMOR] ChangeHat to [" + hatname
+ "] failed. Running in parent context.",
container.getLogger().ERROR);
} else {
inSubHat = true;
}
context.invokeNext(request, response);
if ( inSubHat ) changehat_wrapper.changehat_out(cookie);
}
}
}
apparmor-3.0.4/changehat/tomcat_apparmor/tomcat_5_0/src/com/novell/apparmor/JNIChangeHat.java 0000664 0001750 0001750 00000002010 14201060045 027671 0 ustar jj jj /* ------------------------------------------------------------------
*
* Copyright (C) 2002-2005 Novell/SUSE
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License published by the Free Software Foundation.
*
* ------------------------------------------------------------------ */
package com.novell.apparmor;
import java.nio.*;
/**
*
* JNI interface to AppArmor change_hat(2) call
*
**/
public class JNIChangeHat
{
public static int EPERM = 1;
public static int ENOMEM = 12;
public static int EACCES = 13;
public static int EFAULT = 14;
// Native 'c' function delcaration
public native int changehat_in(String subdomain, int magic_token);
// Native 'c' function delcaration
public native int changehat_out(int magic_token);
static
{
// The runtime system executes a class's static initializer
// when it loads the class.
System.loadLibrary("JNIChangeHat");
}
}
apparmor-3.0.4/changehat/pam_apparmor/ 0000775 0001750 0001750 00000000000 14201060045 015521 5 ustar jj jj apparmor-3.0.4/changehat/pam_apparmor/README 0000664 0001750 0001750 00000006406 14201060045 016407 0 ustar jj jj pam_apparmor - a (linux specific) PAM module to add support for
apparmor's subprocess confinement.
An apparmor profile applies to an executable program; if a portion of
the program needs different access permissions than other portions, the
program can "change hats" via change_hat(2) to a different role, also
known as a subprofile. The pam_apparmor PAM module allows applications
to confine authenticated users into subprofiles based on groupnames,
usernames, or a default profile. To accomplish this, pam_apparmor needs
to be registered as a PAM session module.
Compiling pam_apparmor
----------------------
The pam-development libraries and libapparmor need to be installed
on the build system. 'make' should be all that is needed to build
pam_apparmor.so; 'make rpm' should work on RPM-based systems.
Configuring pam_apparmor
------------------------
To add pam_apparmor support to a pam enabled application, add a line
like the following to the pam configuration file for the application
(usually stored in /etc/pam.d/):
session optional pam_apparmor.so
Likely you will want add the pam_apparmor after other session management
modules. If you make the pam_apparmor module 'required' instead of
'optional', the session will abort if pam_apparmor is not able to
successfully find a hat to change_hat into. Be careful when making it
required; it is possible to cause all attempted logins to the service to
fail if the apparmor policy is insufficient.
By default, pam_apparmor will attempt to change_hat into a hat based
on the primary group name of the user logging in. If that hat fails to
exist, the module will attempt to change_hat into a hat named DEFAULT
(it is recommended to ensure this hat exists in the apparmor profiles
for applications using pam_apparmor).
However, this is configurable by adding an option to the pam configuration
line to modify what order and what attributes pam_apparmor will attempt
to use when attempting to change_hat. To do so, add 'order=' followed by
a comma separated list of types of hats to try. The type of hats
available are:
* 'user' - the username will be used as the hatname
* 'group' - the primary group will be used as the hatname
* 'default' - the string 'DEFAULT' will be used as the hatname.
Generally, this should be the hat of last resort.
The order in the list determines the order the hat will be attempted.
Some example configurations:
# the default behavior
session optional pam_apparmor.so order=group,default
# attempt to use only the username
session optional pam_apparmor.so order=user
# use the username, followed by the primary groupname, followed by
# DEFAULT if the prior hats do not exist in the apparmor profile
session optional pam_apparmor.so order=user,group,default
You can also add a 'debug' flag to the pam_apparmor session line; this
will cause the pam module to report more of what it is attempting to do
to syslog.
References
----------
Project webpage:
http://developer.novell.com/wiki/index.php/Novell_AppArmor
To provide feedback or ask questions please contact the
apparmor-dev@forge.novell.com mail list. This is the development list
for the AppArmor team.
See also: change_hat(3), and the Linux-PAM online documentation at
http://www.kernel.org/pub/linux/libs/pam/Linux-PAM-html/
apparmor-3.0.4/changehat/pam_apparmor/pam_apparmor.h 0000664 0001750 0001750 00000004240 14201060045 020350 0 ustar jj jj /* pam_apparmor module */
/*
* Written by Jesse Michael 2006/08/24
* and Steve Beattie 2006/10/25
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, and the entire permission notice in its entirety,
* including the disclaimer of warranties.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* ALTERNATIVELY, this product may be distributed under the terms of
* the GNU Public License, in which case the provisions of the GPL are
* required INSTEAD OF the above restrictions. (This clause is
* necessary due to a potential bad interaction between the GPL and
* the restrictions contained in a BSD-style copyright.)
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
enum hat_t {
eNoEntry,
eUsername,
eGroupname,
eDefault,
};
typedef enum hat_t hat_t;
#define MAX_HAT_TYPES 3
struct config {
hat_t hat_type[MAX_HAT_TYPES];
};
extern int debug_flag;
extern int get_options(pam_handle_t *pamh, struct config **config,
int argc, const char **argv);
apparmor-3.0.4/changehat/pam_apparmor/Makefile 0000664 0001750 0001750 00000006413 14201060045 017165 0 ustar jj jj # ----------------------------------------------------------------------
# Copyright (c) 1999, 2004, 2005 NOVELL (All rights reserved)
# Copyright (c) 2016 Canonical, Ltd.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# 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, contact Novell, Inc.
# ----------------------------------------------------------------------
NAME=pam_apparmor
all:
COMMONDIR=../../common/
include $(COMMONDIR)/Make.rules
ifdef USE_SYSTEM
LIBAPPARMOR = $(shell if pkg-config --exists libapparmor ; then \
pkg-config --silence-errors --libs libapparmor ; \
elif ldconfig -p | grep -q libapparmor\.so$$ ; then \
echo -lapparmor ; \
fi )
ifeq ($(strip $(LIBAPPARMOR)),)
ERROR_MESSAGE = $(error ${nl}\
************************************************************************${nl}\
Unable to find libapparmor installed on this system; either${nl}\
install libapparmor devel packages, set the LIBAPPARMOR variable${nl}\
manually, or build against in-tree libapparmor.${nl}\
************************************************************************${nl})
endif
LIBAPPARMOR_INCLUDE =
AA_LDLIBS = $(LIBAPPARMOR)
AA_LINK_FLAGS =
else
LIBAPPARMOR_SRC := ../../libraries/libapparmor/
LIBAPPARMOR_INCLUDE_PATH = $(LIBAPPARMOR_SRC)/include
LIBAPPARMOR_PATH := $(LIBAPPARMOR_SRC)/src/.libs/
ifeq ($(realpath $(LIBAPPARMOR_PATH)/libapparmor.a),)
ERROR_MESSAGE = $(error ${nl}\
************************************************************************${nl}\
$(LIBAPPARMOR_PATH)/libapparmor.a is missing; either build against${nl}\
the in-tree libapparmor by building it first and then trying again${nl}\
(see the top-level README for help) or build against the system${nl}\
libapparmor by adding USE_SYSTEM=1 to your make command.${nl}\
************************************************************************${nl})
endif
LIBAPPARMOR_INCLUDE = -I$(LIBAPPARMOR_INCLUDE_PATH)
AA_LINK_FLAGS = -L$(LIBAPPARMOR_PATH)
AA_LDLIBS = -lapparmor
endif
EXTRA_CFLAGS=$(CFLAGS) $(CPPFLAGS) -fPIC -shared -Wall $(EXTRA_WARNINGS) $(LIBAPPARMOR_INCLUDE)
LINK_FLAGS=-Xlinker -x $(AA_LINK_FLAGS) $(LDFLAGS)
LIBS=-lpam $(AA_LDLIBS)
OBJECTS=${NAME}.o get_options.o
.PHONY: libapparmor_check
.SILENT: libapparmor_check
libapparmor_check: ; $(ERROR_MESSAGE)
all: libapparmor_check $(NAME).so docs
.PHONY: docs
# docs: we should have some
docs:
$(NAME).so: ${OBJECTS}
$(CC) $(EXTRA_CFLAGS) $(LINK_FLAGS) -o $@ ${OBJECTS} $(LIBS)
%.o: %.c
$(CC) $(EXTRA_CFLAGS) -c -o $@ $<
# need some better way of determining this
DESTDIR=/
SECDIR ?= ${DESTDIR}/lib/security
.PHONY: install
install: $(NAME).so
install -m 755 -d $(SECDIR)
install -m 755 $(NAME).so $(SECDIR)/
.PHONY: clean
clean:
rm -f core core.* *.so *.o *.s *.a *~
apparmor-3.0.4/changehat/pam_apparmor/pam_apparmor.changes 0000664 0001750 0001750 00000003065 14201060045 021535 0 ustar jj jj -------------------------------------------------------------------
Mon Jul 30 08:16:39 CEST 2007 - sbeattie@suse.de
- Convert libapparmor builddep to libapparmor-devel
-------------------------------------------------------------------
Tue Mar 13 10:27:34 PDT 2007 - jmichael@suse.de
- Use pam_modutil_* wrapper functions when possible
-------------------------------------------------------------------
Tue Oct 31 12:00:00 UTC 2006 - jmichael@suse.de
- Add debug option
-------------------------------------------------------------------
Tue Oct 31 12:00:00 UTC 2006 - sbeattie@suse.de
- Add configuration options to order attempted hat changes
-------------------------------------------------------------------
Wed Oct 25 12:00:00 UTC 2006 - sbeattie@suse.de
- remove auto-editing of pam's common-session
- honor RPM's CFLAGS when building
- add license (same as Linux PAM package).
-------------------------------------------------------------------
Thu Sep 14 12:00:00 UTC 2006 - jmichael@suse.de
- header comment was incorrect
- use pam_get_user() instead of pam_get_item()
- fix read from urandom if 0
-------------------------------------------------------------------
Fri Jan 13 12:00:00 UTC 2006 - sbeattie@suse.de
- Add svn repo number to tarball
-------------------------------------------------------------------
Fri Jan 13 12:00:00 UTC 2006 - jmichael@suse.de
- Make magic tokens harder to guess by pulling them from /dev/urandom
-------------------------------------------------------------------
Wed Dec 21 10:31:40 PST 2005 - jmichael@suse.de
- initial
apparmor-3.0.4/changehat/pam_apparmor/pam_apparmor.c 0000664 0001750 0001750 00000013374 14201060045 020353 0 ustar jj jj /* pam_apparmor module */
/*
* Copyright (c) 2006
* NOVELL (All rights reserved)
*
* Copyright (c) 2010
* Canonical, Ltd. (All rights reserved)
*
* Written by Jesse Michael 2006/08/24
* and Steve Beattie 2006/10/25
*
* Based off of pam_motd by:
* Ben Collins 2005/10/04
* Michael K. Johnson 1996/10/24
*
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
/*
* here, we make a definition for the externally accessible function
* in this file (this definition is required for static a module
* but strongly encouraged generally) it is used to instruct the
* modules include file to define the function prototypes.
*/
#define PAM_SM_SESSION
#include
#include "pam_apparmor.h"
int debug_flag = 0;
#ifndef unused_
#define unused_ __attribute__ ((unused))
#endif
static struct config default_config = {
.hat_type[0] = eGroupname,
.hat_type[1] = eDefault,
.hat_type[2] = eNoEntry,
};
/* --- session management functions (only) --- */
PAM_EXTERN int
pam_sm_close_session (unused_ pam_handle_t *pamh, unused_ int flags,
unused_ int argc, unused_ const char **argv)
{
return PAM_IGNORE;
}
PAM_EXTERN
int pam_sm_open_session(pam_handle_t *pamh, unused_ int flags,
int argc, const char **argv)
{
int fd, retval, pam_retval = PAM_SUCCESS;
unsigned int magic_token;
const char *user;
struct passwd *pw;
struct group *gr;
struct config *config = NULL;
int i;
if ((retval = get_options(pamh, &config, argc, argv)) != 0)
return retval;
if (!config)
config = &default_config;
/* grab the target user name */
retval = pam_get_user(pamh, &user, NULL);
if (retval != PAM_SUCCESS || user == NULL || *user == '\0') {
pam_syslog(pamh, LOG_ERR, "Can't determine user\n");
return PAM_USER_UNKNOWN;
}
pw = pam_modutil_getpwnam(pamh, user);
if (!pw) {
pam_syslog(pamh, LOG_ERR, "Can't determine group for user %s\n", user);
return PAM_PERM_DENIED;
}
gr = pam_modutil_getgrgid(pamh, pw->pw_gid);
if (!gr || !gr->gr_name) {
pam_syslog(pamh, LOG_ERR, "Can't read info for group %d\n", pw->pw_gid);
return PAM_PERM_DENIED;
}
fd = open("/dev/urandom", O_RDONLY);
if (fd < 0) {
pam_syslog(pamh, LOG_ERR, "Can't open /dev/urandom\n");
return PAM_PERM_DENIED;
}
/* the magic token needs to be non-zero otherwise, we won't be able
* to probe for hats */
do {
retval = pam_modutil_read(fd,
(void *)&magic_token,
sizeof(magic_token));
if (retval < 0) {
pam_syslog(pamh, LOG_ERR, "Can't read from /dev/urandom\n");
close(fd);
return PAM_PERM_DENIED;
}
} while ((magic_token == 0) || (retval != sizeof(magic_token)));
close(fd);
pam_retval = PAM_SUCCESS;
for (i = 0; i < MAX_HAT_TYPES && config->hat_type[i] != eNoEntry; i++) {
const char *hat = NULL;
switch (config->hat_type[i]) {
case eGroupname:
hat = gr->gr_name;
if (debug_flag)
pam_syslog(pamh, LOG_DEBUG, "Using groupname '%s'\n", hat);
break;
case eUsername:
hat = user;
if (debug_flag)
pam_syslog(pamh, LOG_DEBUG, "Using username '%s'\n", hat);
break;
case eDefault:
if (debug_flag)
pam_syslog(pamh, LOG_DEBUG, "Using DEFAULT\n");
hat = "DEFAULT";
break;
default:
pam_syslog(pamh, LOG_ERR, "Unknown value in hat table: %x\n",
config->hat_type[i]);
goto nodefault;
break;
}
retval = change_hat(hat, magic_token);
if (retval == 0) {
/* success, let's bail */
if (debug_flag)
pam_syslog(pamh, LOG_DEBUG, "Successfully changed to hat '%s'\n", hat);
goto out;
}
switch (errno) {
/* case EPERM: */ /* Can't enable until ECHILD patch gets accepted, and we can
* distinguish between unconfined and confined-but-no-hats */
case EINVAL:
/* apparmor is not loaded or application is unconfined,
* stop attempting to use change_hat */
if (debug_flag)
pam_syslog(pamh, LOG_DEBUG,
"AppArmor not loaded, or application is unconfined\n");
pam_retval = PAM_SUCCESS;
goto out;
break;
case ECHILD:
/* application is confined but has no hats,
* stop attempting to use change_hat */
goto nodefault;
break;
case EACCES:
case ENOENT:
/* failed to change into attempted hat, so we'll
* jump back out and try the next one */
break;
default:
pam_syslog(pamh, LOG_ERR, "Unknown error occurred changing to %s hat: %s\n",
hat, strerror(errno));
/* give up? */
pam_retval = PAM_SYSTEM_ERR;
goto out;
}
retval = change_hat(NULL, magic_token);
if (retval != 0) {
/* changing into the specific hat and attempting to
* jump back out both failed. that most likely
* means that either apparmor is not loaded or we
* don't have a profile loaded for this application.
* in this case, we want to allow the pam operation
* to succeed. */
goto out;
}
}
nodefault:
/* if we got here, we were unable to change into any of the hats
* we attempted. */
pam_syslog(pamh, LOG_ERR, "Can't change to any hat\n");
pam_retval = PAM_SESSION_ERR;
out:
/* zero out the magic token so an attacker wouldn't be able to
* just grab it out of process memory and instead would need to
* brute force it */
memset(&magic_token, 0, sizeof(magic_token));
if (config && config != &default_config)
free(config);
return pam_retval;
}
#ifdef PAM_STATIC
/* static module data */
struct pam_module _pam_apparmor_modstruct = {
"pam_apparmor",
NULL,
NULL,
NULL,
pam_sm_open_session,
pam_sm_close_session,
NULL,
};
#endif
/* end of module definition */
apparmor-3.0.4/changehat/pam_apparmor/get_options.c 0000664 0001750 0001750 00000011057 14201060045 020223 0 ustar jj jj /*
* Written by Steve Beattie 2006/10/25
*
* Modeled after the option parsing code in pam_unix2 by:
* Copyright (c) 2006 SUSE Linux Products GmbH, Nuernberg, Germany.
* Copyright (c) 2002, 2003, 2004 SuSE GmbH Nuernberg, Germany.
* Author: Thorsten Kukuk
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, and the entire permission notice in its entirety,
* including the disclaimer of warranties.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* ALTERNATIVELY, this product may be distributed under the terms of
* the GNU Public License, in which case the provisions of the GPL are
* required INSTEAD OF the above restrictions. (This clause is
* necessary due to a potential bad interaction between the GPL and
* the restrictions contained in a BSD-style copyright.)
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define _GNU_SOURCE /* for strndup() */
#include
#include
#include
#include
#include
#include
#define PAM_SM_SESSION
#include
#include "pam_apparmor.h"
#define DEBUG_STRING "debug"
#define ORDER_PREFIX "order="
static int parse_option(pam_handle_t *pamh, struct config **config, const char *argv)
{
const char *opts;
if (argv == NULL || argv[0] == '\0')
return 0;
if (strcasecmp(argv, DEBUG_STRING) == 0) {
debug_flag = 1;
return 0;
} else if (strncasecmp(argv, ORDER_PREFIX, strlen(ORDER_PREFIX)) != 0) {
pam_syslog (pamh, LOG_ERR, "Unknown option: `%s'\n", argv);
return PAM_SESSION_ERR;
}
opts = argv + strlen(ORDER_PREFIX);
while (*opts != '\0') {
hat_t hat;
char *opt, *comma;
int i;
comma = index(opts, ',');
if (comma)
opt = strndup(opts, comma - opts);
else
opt = strdup(opts);
if (!opt) {
pam_syslog(pamh, LOG_ERR, "Memory allocation error: %s",
strerror(errno));
return PAM_SESSION_ERR;
}
if (strcasecmp(opt, "group") == 0)
hat = eGroupname;
else if (strcasecmp(opt, "user") == 0)
hat = eUsername;
else if (strcasecmp(opt, "default") == 0)
hat = eDefault;
else {
pam_syslog (pamh, LOG_ERR, "Unknown option: `%s'\n", opt);
free(opt);
return PAM_SESSION_ERR;
}
if (!(*config)) {
struct config *new_cfg = malloc(sizeof(**config));
if (!new_cfg) {
pam_syslog(pamh, LOG_ERR, "Memory allocation error: %s",
strerror(errno));
free(opt);
return PAM_SESSION_ERR;
}
new_cfg->hat_type[0] = eNoEntry;
new_cfg->hat_type[1] = eNoEntry;
new_cfg->hat_type[2] = eNoEntry;
(*config) = new_cfg;
}
/* Find free table entry, looking for duplicates */
for (i = 0; i < MAX_HAT_TYPES && (*config)->hat_type[i] != eNoEntry; i++) {
if ((*config)->hat_type[i] == hat) {
pam_syslog(pamh, LOG_ERR, "Duplicate hat type: %s\n", opt);
free(opt);
free(*config);
(*config) = NULL;
return PAM_SESSION_ERR;
}
}
if (i >= MAX_HAT_TYPES) {
pam_syslog(pamh, LOG_ERR, "Unable to add hat type '%s'\n", opt);
return PAM_SESSION_ERR;
}
(*config)->hat_type[i] = hat;
free(opt);
if (comma)
opts = comma + 1;
else
opts += strlen(opts);
}
return 0;
}
int get_options(pam_handle_t *pamh, struct config **config, int argc, const char **argv)
{
int retval = 0;
/* Parse parameters for module */
for ( ; argc-- > 0; argv++) {
int rc = parse_option(pamh, config, *argv);
if (rc != 0)
retval = rc;
}
return retval;
}
apparmor-3.0.4/changehat/pam_apparmor/COPYING 0000664 0001750 0001750 00000003740 14201060045 016560 0 ustar jj jj The pam_apparmor package is licensed under the same license as Linux-PAM
, quoted below:
-------------------------------------------------------------------------
Redistribution and use in source and binary forms of Linux-PAM, with
or without modification, are permitted provided that the following
conditions are met:
1. Redistributions of source code must retain any existing copyright
notice, and this entire permission notice in its entirety,
including the disclaimer of warranties.
2. Redistributions in binary form must reproduce all prior and current
copyright notices, this list of conditions, and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
3. The name of any author may not be used to endorse or promote
products derived from this software without their specific prior
written permission.
ALTERNATIVELY, this product may be distributed under the terms of the
GNU General Public License, in which case the provisions of the GNU
GPL are required INSTEAD OF the above restrictions. (This clause is
necessary due to a potential conflict between the GNU GPL and the
restrictions contained in a BSD-style copyright.)
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
-------------------------------------------------------------------------
apparmor-3.0.4/changehat/mod_apparmor/ 0000775 0001750 0001750 00000000000 14201060303 015520 5 ustar jj jj apparmor-3.0.4/changehat/mod_apparmor/mod_apparmor.c 0000664 0001750 0001750 00000033404 14201060045 020353 0 ustar jj jj /*
* Copyright (c) 2004, 2005, 2006 NOVELL (All rights reserved)
* Copyright (c) 2014 Canonical, Ltd. (All rights reserved)
*
* The mod_apparmor module is licensed under the terms of the GNU
* Lesser General Public License, version 2.1. Please see the file
* COPYING.LGPL.
*
* mod_apparmor - (apache 2.0.x)
* Author: Steve Beattie
*
* This currently only implements change_hat functionality, but could be
* extended for other stuff we decide to do.
*/
#include "ap_config.h"
#include "httpd.h"
#include "http_config.h"
#include "http_request.h"
#include "http_log.h"
#include "http_main.h"
#include "http_protocol.h"
#include "util_filter.h"
#include "apr.h"
#include "apr_strings.h"
#include "apr_lib.h"
#include
#include
/* #define DEBUG */
#ifndef unused_
#define unused_ __attribute__ ((unused))
#endif
/* should the following be configurable? */
#define DEFAULT_HAT "HANDLING_UNTRUSTED_INPUT"
#define DEFAULT_URI_HAT "DEFAULT_URI"
/* Compatibility with apache 2.2 */
#if AP_SERVER_MAJORVERSION_NUMBER == 2 && AP_SERVER_MINORVERSION_NUMBER < 3
#define APLOG_TRACE1 APLOG_DEBUG
server_rec *ap_server_conf = NULL;
#endif
#ifdef APLOG_USE_MODULE
APLOG_USE_MODULE(apparmor);
#endif
module AP_MODULE_DECLARE_DATA apparmor_module;
static unsigned long magic_token = 0;
static int inside_default_hat = 0;
typedef struct {
const char *hat_name;
char *path;
} apparmor_dir_cfg;
typedef struct {
const char *hat_name;
int is_initialized;
} apparmor_srv_cfg;
/* aa_init() gets invoked in the post_config stage of apache.
* Unfortunately, apache reads its config once when it starts up, then
* it re-reads it when goes into its restart loop, where it starts it's
* children. This means we cannot call change_hat here, as the modules
* memory will be wiped out, and the magic_token will be lost, so apache
* wouldn't be able to change_hat back out. */
static int
aa_init(apr_pool_t *p, unused_ apr_pool_t *plog, unused_ apr_pool_t *ptemp, unused_ server_rec *s)
{
apr_file_t *file;
apr_size_t size = sizeof(magic_token);
int ret;
ret = apr_file_open (&file, "/dev/urandom", APR_READ, APR_OS_DEFAULT, p);
if (!ret) {
apr_file_read(file, (void *) &magic_token, &size);
apr_file_close(file);
} else {
ap_log_error(APLOG_MARK, APLOG_ERR, errno, ap_server_conf,
"Failed to open /dev/urandom");
}
ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, ap_server_conf,
"Opened /dev/urandom successfully");
return OK;
}
/* As each child starts up, we'll change_hat into a default hat, mostly
* to protect ourselves from bugs in parsing network input, but before
* we change_hat to the uri specific hat. */
static void
aa_child_init(unused_ apr_pool_t *p, unused_ server_rec *s)
{
int ret;
ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, ap_server_conf,
"init: calling change_hat with '%s'", DEFAULT_HAT);
ret = aa_change_hat(DEFAULT_HAT, magic_token);
if (ret < 0) {
ap_log_error(APLOG_MARK, APLOG_ERR, errno, ap_server_conf,
"Failed to change_hat to '%s'", DEFAULT_HAT);
} else {
inside_default_hat = 1;
}
}
static void
debug_dump_uri(request_rec *r)
{
apr_uri_t *uri = &r->parsed_uri;
if (uri)
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "Dumping uri info "
"scheme='%s' host='%s' path='%s' query='%s' fragment='%s'",
uri->scheme, uri->hostname, uri->path, uri->query,
uri->fragment);
else
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "Asked to dump NULL uri");
}
/*
aa_enter_hat will attempt to change_hat in the following order:
(1) to a hatname in a location directive
(2) to the server name or a defined per-server default
(3) to the server name + "-" + uri
(4) to the uri
(5) to DEFAULT_URI
(6) back to the parent profile
*/
static int
aa_enter_hat(request_rec *r)
{
int aa_ret = -1;
apparmor_dir_cfg *dcfg = (apparmor_dir_cfg *)
ap_get_module_config(r->per_dir_config, &apparmor_module);
apparmor_srv_cfg *scfg = (apparmor_srv_cfg *)
ap_get_module_config(r->server->module_config, &apparmor_module);
const char *aa_hat_array[6] = { NULL, NULL, NULL, NULL, NULL, NULL };
int i = 0;
char *aa_label, *aa_mode, *aa_hat;
const char *vhost_uri;
debug_dump_uri(r);
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "aa_enter_hat (%s) n:0x%lx p:0x%lx main:0x%lx",
dcfg->path, (unsigned long) r->next, (unsigned long) r->prev,
(unsigned long) r->main);
/* We only call change_hat for the main request, not subrequests */
if (r->main)
return OK;
if (inside_default_hat) {
aa_change_hat(NULL, magic_token);
inside_default_hat = 0;
}
if (dcfg != NULL && dcfg->hat_name != NULL) {
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
"[dcfg] adding hat '%s' to aa_change_hat vector", dcfg->hat_name);
aa_hat_array[i++] = dcfg->hat_name;
}
if (scfg) {
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "Dumping scfg info: "
"scfg='0x%lx' scfg->hat_name='%s'",
(unsigned long) scfg, scfg->hat_name);
} else {
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "scfg is null");
}
if (scfg != NULL) {
if (scfg->hat_name != NULL) {
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
"[scfg] adding hat '%s' to aa_change_hat vector", scfg->hat_name);
aa_hat_array[i++] = scfg->hat_name;
} else {
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
"[scfg] adding server_name '%s' to aa_change_hat vector",
r->server->server_hostname);
aa_hat_array[i++] = r->server->server_hostname;
}
vhost_uri = apr_pstrcat(r->pool, r->server->server_hostname, "-", r->uri, NULL);
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
"[vhost+uri] adding vhost+uri '%s' to aa_change_hat vector", vhost_uri);
aa_hat_array[i++] = vhost_uri;
}
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
"[uri] adding uri '%s' to aa_change_hat vector", r->uri);
aa_hat_array[i++] = r->uri;
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
"[default] adding '%s' to aa_change_hat vector", DEFAULT_URI_HAT);
aa_hat_array[i++] = DEFAULT_URI_HAT;
aa_ret = aa_change_hatv(aa_hat_array, magic_token);
if (aa_ret < 0) {
ap_log_rerror(APLOG_MARK, APLOG_WARNING, errno, r, "aa_change_hatv call failed");
}
/* Check to see if a defined AAHatName or AADefaultHatName would
* apply, but wasn't the hat we landed up in; report a warning if
* that's the case. */
aa_ret = aa_getcon(&aa_label, &aa_mode);
if (aa_ret < 0) {
ap_log_rerror(APLOG_MARK, APLOG_WARNING, errno, r, "aa_getcon call failed");
} else {
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r,
"AA checks: aa_getcon result is '%s', mode '%s'", aa_label, aa_mode);
/* TODO: use libapparmor get hat_name fn here once it is implemented */
aa_hat = strstr(aa_label, "//");
if (aa_hat != NULL && strcmp(aa_mode, "enforce") == 0) {
aa_hat += 2; /* skip "//" */
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r,
"AA checks: apache is in hat '%s', mode '%s'", aa_hat, aa_mode);
if (dcfg != NULL && dcfg->hat_name != NULL) {
if (strcmp(aa_hat, dcfg->hat_name) != 0)
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r,
"AAHatName '%s' applies, but does not appear to be a hat in the apache apparmor policy",
dcfg->hat_name);
} else if (scfg != NULL && scfg->hat_name != NULL) {
if (strcmp(aa_hat, scfg->hat_name) != 0 &&
strcmp(aa_hat, r->uri) != 0)
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r,
"AADefaultHatName '%s' applies, but does not appear to be a hat in the apache apparmor policy",
scfg->hat_name);
}
}
free(aa_label);
}
return OK;
}
static int
aa_exit_hat(request_rec *r)
{
int aa_ret;
apparmor_dir_cfg *dcfg = (apparmor_dir_cfg *)
ap_get_module_config(r->per_dir_config, &apparmor_module);
/* apparmor_srv_cfg *scfg = (apparmor_srv_cfg *)
ap_get_module_config(r->server->module_config, &apparmor_module); */
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "exiting change_hat: dir hat %s dir path %s",
dcfg->hat_name, dcfg->path);
/* can convert the following back to aa_change_hat() when the
* aa_change_hat() bug addressed in trunk commit 2329 lands in most
* system libapparmors */
aa_change_hatv(NULL, magic_token);
aa_ret = aa_change_hat(DEFAULT_HAT, magic_token);
if (aa_ret < 0) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
"Failed to change_hat to '%s'", DEFAULT_HAT);
} else {
inside_default_hat = 1;
}
return OK;
}
static const char *
aa_cmd_ch_path(unused_ cmd_parms *cmd, unused_ void *mconfig, const char *parm1)
{
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, "directory config change hat %s",
parm1 ? parm1 : "DEFAULT");
apparmor_dir_cfg *dcfg = mconfig;
if (parm1 != NULL) {
dcfg->hat_name = parm1;
} else {
dcfg->hat_name = "DEFAULT";
}
return NULL;
}
static int path_warn_once;
static const char *
immunix_cmd_ch_path(cmd_parms *cmd, void *mconfig, const char *parm1)
{
if (path_warn_once == 0) {
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, "ImmHatName is "
"deprecated, please use AAHatName instead");
path_warn_once = 1;
}
return aa_cmd_ch_path(cmd, mconfig, parm1);
}
static const char *
aa_cmd_ch_srv(cmd_parms *cmd, unused_ void *mconfig, const char *parm1)
{
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, "server config change hat %s",
parm1 ? parm1 : "DEFAULT");
apparmor_srv_cfg *scfg = (apparmor_srv_cfg *)
ap_get_module_config(cmd->server->module_config, &apparmor_module);
if (parm1 != NULL) {
scfg->hat_name = parm1;
} else {
scfg->hat_name = "DEFAULT";
}
return NULL;
}
static int srv_warn_once;
static const char *
immunix_cmd_ch_srv(cmd_parms *cmd, void *mconfig, const char *parm1)
{
if (srv_warn_once == 0) {
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, "ImmDefaultHatName is "
"deprecated, please use AADefaultHatName instead");
srv_warn_once = 1;
}
return aa_cmd_ch_srv(cmd, mconfig, parm1);
}
static void *
aa_create_dir_config(apr_pool_t *p, char *path)
{
apparmor_dir_cfg *newcfg = (apparmor_dir_cfg *) apr_pcalloc(p, sizeof(*newcfg));
ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, ap_server_conf,
"aa_create_dir_cfg (%s)", path ? path : ":no path:");
if (newcfg == NULL) {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf,
"aa_create_dir_config: couldn't alloc dir config");
return NULL;
}
newcfg->path = apr_pstrdup(p, path ? path : ":no path:");
return newcfg;
}
/* XXX: Should figure out an appropriate action to take here, if any
static void *
aa_merge_dir_config(apr_pool_t *p, void *parent, void *child)
{
apparmor_dir_cfg *newcfg = (apparmor_dir_cfg *) apr_pcalloc(p, sizeof(*newcfg));
ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, ap_server_conf, "in immunix_merge_dir ()");
if (newcfg == NULL)
return NULL;
return newcfg;
}
*/
static void *
aa_create_srv_config(apr_pool_t *p, unused_ server_rec *srv)
{
apparmor_srv_cfg *newcfg = (apparmor_srv_cfg *) apr_pcalloc(p, sizeof(*newcfg));
ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, ap_server_conf,
"in aa_create_srv_config");
if (newcfg == NULL) {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf,
"aa_create_srv_config: couldn't alloc srv config");
return NULL;
}
return newcfg;
}
static const command_rec mod_apparmor_cmds[] = {
AP_INIT_TAKE1(
"ImmHatName",
immunix_cmd_ch_path,
NULL,
ACCESS_CONF,
""
),
AP_INIT_TAKE1(
"ImmDefaultHatName",
immunix_cmd_ch_srv,
NULL,
RSRC_CONF,
""
),
AP_INIT_TAKE1(
"AAHatName",
aa_cmd_ch_path,
NULL,
ACCESS_CONF,
""
),
AP_INIT_TAKE1(
"AADefaultHatName",
aa_cmd_ch_srv,
NULL,
RSRC_CONF,
""
),
{ NULL }
};
static void
register_hooks(unused_ apr_pool_t *p)
{
ap_hook_post_config(aa_init, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_child_init(aa_child_init, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_access_checker(aa_enter_hat, NULL, NULL, APR_HOOK_FIRST);
/* ap_hook_post_read_request(aa_enter_hat, NULL, NULL, APR_HOOK_FIRST); */
ap_hook_log_transaction(aa_exit_hat, NULL, NULL, APR_HOOK_LAST);
}
module AP_MODULE_DECLARE_DATA apparmor_module = {
STANDARD20_MODULE_STUFF,
aa_create_dir_config, /* dir config creater */
NULL, /* dir merger --- default is to override */
/* immunix_merge_dir_config, */ /* dir merger --- default is to override */
aa_create_srv_config, /* server config */
NULL, /* merge server config */
mod_apparmor_cmds, /* command table */
register_hooks /* register hooks */
};
apparmor-3.0.4/changehat/mod_apparmor/COPYING.LGPL 0000664 0001750 0001750 00000063500 14201060045 017317 0 ustar jj jj GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
apparmor-3.0.4/changehat/mod_apparmor/Makefile 0000664 0001750 0001750 00000007312 14201060045 017166 0 ustar jj jj # ----------------------------------------------------------------------
# Copyright (c) 2004, 2005 NOVELL (All rights reserved)
# Copyright (c) 2016 Canonical, Ltd.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# 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, contact Novell, Inc.
# ----------------------------------------------------------------------
NAME:=apache2-mod_apparmor
all:
COMMONDIR=../../common/
include $(COMMONDIR)/Make.rules
TARGET:=mod_apparmor.so
MANPAGES=mod_apparmor.8
APXS:=$(shell if [ -x "/usr/sbin/apxs2" ] ; then \
echo "/usr/sbin/apxs2" ; \
elif [ -x "/usr/sbin/apxs" ] ; then \
echo "/usr/sbin/apxs" ; \
elif [ -x "/usr/bin/apxs2" ] ; then \
echo "/usr/bin/apxs2" ; \
elif [ -x "/usr/bin/apxs" ] ; then \
echo "/usr/bin/apxs" ; \
else \
echo "apxs" ; \
fi )
APXS_INSTALL_DIR=$(shell ${APXS} -q LIBEXECDIR)
DESTDIR=
ifdef USE_SYSTEM
LIBAPPARMOR = $(shell if pkg-config --exists libapparmor ; then \
pkg-config --silence-errors --libs libapparmor ; \
elif ldconfig -p | grep -q libapparmor\.so$$ ; then \
echo -lapparmor ; \
fi )
ifeq ($(strip $(LIBAPPARMOR)),)
ERROR_MESSAGE = $(error ${nl}\
************************************************************************${nl}\
Unable to find libapparmor installed on this system; either${nl}\
install libapparmor devel packages, set the LIBAPPARMOR variable${nl}\
manually, or build against in-tree libapparmor.${nl}\
************************************************************************${nl})
endif # LIBAPPARMOR not set
LDLIBS += $(LIBAPPARMOR)
else
LIBAPPARMOR_SRC := ../../libraries/libapparmor/
LIBAPPARMOR_INCLUDE = $(LIBAPPARMOR_SRC)/include
LIBAPPARMOR_PATH := $(LIBAPPARMOR_SRC)/src/.libs/
ifeq ($(realpath $(LIBAPPARMOR_PATH)/libapparmor.a),)
ERROR_MESSAGE = $(error ${nl}\
************************************************************************${nl}\
$(LIBAPPARMOR_PATH)/libapparmor.a is missing; either build against${nl}\
the in-tree libapparmor by building it first and then trying again${nl}\
(see the top-level README for help) or build against the system${nl}\
libapparmor by adding USE_SYSTEM=1 to your make command.${nl}\
************************************************************************${nl})
endif
# Need to pass -Wl twice here to get past both apxs2 and libtool, as
# libtool will add the path to the RPATH of the library if passed -L/some/path
LIBAPPARMOR_FLAGS = -I$(LIBAPPARMOR_INCLUDE) -Wl,-Wl,-L$(LIBAPPARMOR_PATH)
LDLIBS = -lapparmor
endif
APXS_CFLAGS="-Wc,$(EXTRA_WARNINGS)"
.PHONY: libapparmor_check
.SILENT: libapparmor_check
libapparmor_check: ; $(ERROR_MESSAGE)
all: libapparmor_check $(TARGET) docs
.PHONY: docs
docs: ${MANPAGES} ${HTMLMANPAGES}
%.so: %.c
${APXS} ${LIBAPPARMOR_FLAGS} ${APXS_CFLAGS} -c $< ${LDLIBS}
mv .libs/$@ .
.PHONY: install
install: ${TARGET} ${MANPAGES}
mkdir -p ${DESTDIR}/${APXS_INSTALL_DIR}
install -m 755 $< ${DESTDIR}/${APXS_INSTALL_DIR}
$(MAKE) install_manpages DESTDIR=${DESTDIR}
.PHONY: clean
clean: pod_clean
rm -rf .libs
rm -f *.la *.lo *.so *.o *.slo
.PHONY: check
check: check_pod_files
apparmor-3.0.4/changehat/mod_apparmor/pod2htmd.tmp 0000664 0001750 0001750 00000000003 14201060303 017754 0 ustar jj jj
.
apparmor-3.0.4/changehat/mod_apparmor/frob_sysconfig 0000775 0001750 0001750 00000004232 14201060045 020466 0 ustar jj jj #!/usr/bin/perl -w
#
# ----------------------------------------------------------------------
# Copyright (c) 2004, 2005 NOVELL (All rights reserved)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# 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, contact Novell, Inc.
# ----------------------------------------------------------------------
# read /etc/sysconfig/apache2 and add "change_hat" to the apache
# modules found there
use Getopt::Long;
use File::Temp qw/ :mktemp /;
my $module="apparmor";
sub usage() {
print "$0\t--file= modify \n";
print "\t\t\t--remove remove option from config file\n";
print "\t\t\t--help this help\n";
exit(0);
}
my ($conffile,$help,$remove);
GetOptions(
"file=s" => \$conffile,
"remove" => \$remove,
"help!" => \$help
) or usage();
usage() if $help;
if (defined $conffile) {
$old = $conffile;
chomp($old);
} else {
$old="/etc/sysconfig/apache2";
}
open(MENU,"<$old") or die "Fatal: can't open $old: $!";
($fh, $file) = mkstemp($old . "XXXXXX" );
while (