00001 /******************************************************************** 00002 00003 Copyright 2006, ACCESS Systems Americas, Inc. All rights reserved. 00004 00005 The contents of this file are subject to the Mozilla Public License Version 00006 1.1 (the "License"); you may not use this file except in compliance with 00007 the License. You may obtain a copy of the License at 00008 http://www.mozilla.org/MPL/ 00009 00010 Software distributed under the License is distributed on an "AS IS" basis, 00011 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 00012 for the specific language governing rights and limitations under the 00013 License. 00014 00015 The Original Code is the entire contents of this file. 00016 00017 The Initial Developer of the Original Code is ACCESS Systems Americas, Inc. 00018 00019 Portions created by ACCESS Systems Americas, Inc. are Copyright © 2006. All 00020 Rights Reserved. 00021 00022 Contributor(s): none. 00023 00024 ********************************************************************/ 00025 00035 #ifndef _ALP_NLPD_H 00036 #define _ALP_NLPD_H 1 00037 00038 #include <stdlib.h> 00039 #include <stdio.h> 00040 #include <string.h> 00041 #include <unistd.h> 00042 #include <dirent.h> // used for opendir() 00043 #include <fcntl.h> // used for open() 00044 #include <signal.h> // used for kill() 00045 #include <grp.h> 00046 #include <sys/prctl.h> 00047 #include <sys/types.h> // used for opendir() 00048 #include <sys/stat.h> // used for open() 00049 #include <hiker/security.h> 00050 #include <hiker/bundlemgr.h> 00051 #include <hiker/traces.h> 00052 #include <hiker/config.h> 00053 00054 #ifdef __cplusplus 00055 extern "C" { 00056 #endif 00057 00058 #define OVERWRITE 1 00059 #define BACKCHANNEL "alp_appserver_cookiecutter_channel" 00060 #define MAX_PATH_LEN 512 00061 00062 // 00063 // Given a null terminated string of the form 00064 // [NAME=VALUE; | NAME;]+ this will set each 00065 // environment NAME = VALUE or in the case of 00066 // NAME; it will unset that environment variable. 00067 // 00068 // Example "HOME=/home/david;DISTCC;SHELL=/usr/bin/sh" 00069 // Will set $HOME = /home/david 00070 // Will unset $DISTCC and will 00071 // set $SHELL = /usr/bin/sh 00072 // 00073 void alp_prv_SetUpEnv(char *env); 00074 00075 // 00076 // Given a package and the length of that packages this will set up 00077 // the runtime GID and UIDs for the process to run that package. 00078 // 00079 00080 unsigned int alp_get_security_id( AlpBundle bundle ); 00081 int alp_set_security_parameters( unsigned int security_id ); 00082 00083 00084 // 00085 // This function renames a running process. 00086 // It does not change the /proc/procID/exe link. 00087 // It does seem to change it for the "ps" command 00088 // and the "top" command. 00089 // 00090 // This returns 0 if it succeed. 1 if it had 00091 // a problem. There is no error recovery possible 00092 // so this is just informational. An example of 00093 // a 1 would be if the new name of the process is 00094 // long than the old name. In that case it only 00095 // copies what will fit. 00096 // 00097 int alp_prv_rename_process( char *NewName, char *argv[] ); 00098 00099 // Lets you signal all processes that are run from a binary 00100 // who's path is pointed to by the char *. This is usefull 00101 // for killing NLPD because it changes it's name but it can't 00102 // change it's backing store. 00103 // 00104 int alp_prv_signal_all( const char *, int ); 00105 00106 // Private functions 00107 static int alp_prv_file_is_digits( const struct dirent *); 00108 static char *alp_prv_image_path( char *current ); 00109 00110 #ifdef __cplusplus 00111 } 00112 #endif 00113 #endif /* nlpd_bits.h */