Apache-Admin-Config-0.94/0000755000175000000620000000000010440613077014626 5ustar rsstaff00000000000000Apache-Admin-Config-0.94/t/0000755000175000000620000000000010440613077015071 5ustar rsstaff00000000000000Apache-Admin-Config-0.94/t/httpd.conf-dist0000644000175000000620000007165107523625521020043 0ustar rsstaff00000000000000# # Based upon the NCSA server configuration files originally by Rob McCool. # # This is the main Apache server configuration file. It contains the # configuration directives that give the server its instructions. # See for detailed information about # the directives. # # Do NOT simply read the instructions in here without understanding # what they do. They're here only as hints or reminders. If you are unsure # consult the online docs. You have been warned. # # After this file is processed, the server will look for and process # @@ServerRoot@@/conf/srm.conf and then @@ServerRoot@@/conf/access.conf # unless you have overridden these with ResourceConfig and/or # AccessConfig directives here. # # The configuration directives are grouped into three basic sections: # 1. Directives that control the operation of the Apache server process as a # whole (the 'global environment'). # 2. Directives that define the parameters of the 'main' or 'default' server, # which responds to requests that aren't handled by a virtual host. # These directives also provide default values for the settings # of all virtual hosts. # 3. Settings for virtual hosts, which allow Web requests to be sent to # different IP addresses or hostnames and have them handled by the # same Apache server process. # # Configuration and logfile names: If the filenames you specify for many # of the server's control files begin with "/" (or "drive:/" for Win32), the # server will use that explicit path. If the filenames do *not* begin # with "/", the value of ServerRoot is prepended -- so "logs/foo.log" # with ServerRoot set to "/usr/local/apache" will be interpreted by the # server as "/usr/local/apache/logs/foo.log". # ### Section 1: Global Environment # # The directives in this section affect the overall operation of Apache, # such as the number of concurrent requests it can handle or where it # can find its configuration files. # # # ServerType is either inetd, or standalone. Inetd mode is only supported on # Unix platforms. # ServerType standalone # # ServerRoot: The top of the directory tree under which the server's # configuration, error, and log files are kept. # # NOTE! If you intend to place this on an NFS (or otherwise network) # mounted filesystem then please read the LockFile documentation # (available at ); # you will save yourself a lot of trouble. # # Do NOT add a slash at the end of the directory path. # ServerRoot "@@ServerRoot@@" # # The LockFile directive sets the path to the lockfile used when Apache # is compiled with either USE_FCNTL_SERIALIZED_ACCEPT or # USE_FLOCK_SERIALIZED_ACCEPT. This directive should normally be left at # its default value. The main reason for changing it is if the logs # directory is NFS mounted, since the lockfile MUST BE STORED ON A LOCAL # DISK. The PID of the main server process is automatically appended to # the filename. # #LockFile logs/accept.lock # # PidFile: The file in which the server should record its process # identification number when it starts. # PidFile logs/httpd.pid # # ScoreBoardFile: File used to store internal server process information. # Not all architectures require this. But if yours does (you'll know because # this file will be created when you run Apache) then you *must* ensure that # no two invocations of Apache share the same scoreboard file. # ScoreBoardFile logs/apache_runtime_status # # In the standard configuration, the server will process this file, # srm.conf, and access.conf in that order. The latter two files are # now distributed empty, as it is recommended that all directives # be kept in a single file for simplicity. The commented-out values # below are the built-in defaults. You can have the server ignore # these files altogether by using "/dev/null" (for Unix) or # "nul" (for Win32) for the arguments to the directives. # #ResourceConfig conf/srm.conf #AccessConfig conf/access.conf # # Timeout: The number of seconds before receives and sends time out. # Timeout 300 # # KeepAlive: Whether or not to allow persistent connections (more than # one request per connection). Set to "Off" to deactivate. # KeepAlive On # # MaxKeepAliveRequests: The maximum number of requests to allow # during a persistent connection. Set to 0 to allow an unlimited amount. # We recommend you leave this number high, for maximum performance. # MaxKeepAliveRequests 100 # # KeepAliveTimeout: Number of seconds to wait for the next request from the # same client on the same connection. # KeepAliveTimeout 15 # # Server-pool size regulation. Rather than making you guess how many # server processes you need, Apache dynamically adapts to the load it # sees --- that is, it tries to maintain enough server processes to # handle the current load, plus a few spare servers to handle transient # load spikes (e.g., multiple simultaneous requests from a single # Netscape browser). # # It does this by periodically checking how many servers are waiting # for a request. If there are fewer than MinSpareServers, it creates # a new spare. If there are more than MaxSpareServers, some of the # spares die off. The default values are probably OK for most sites. # MinSpareServers 5 MaxSpareServers 10 # # Number of servers to start initially --- should be a reasonable ballpark # figure. # StartServers 5 # # Limit on total number of servers running, i.e., limit on the number # of clients who can simultaneously connect --- if this limit is ever # reached, clients will be LOCKED OUT, so it should NOT BE SET TOO LOW. # It is intended mainly as a brake to keep a runaway server from taking # the system with it as it spirals down... # MaxClients 150 # # MaxRequestsPerChild: the number of requests each child process is # allowed to process before the child dies. The child will exit so # as to avoid problems after prolonged use when Apache (and maybe the # libraries it uses) leak memory or other resources. On most systems, this # isn't really needed, but a few (such as Solaris) do have notable leaks # in the libraries. For these platforms, set to something like 10000 # or so; a setting of 0 means unlimited. # # NOTE: This value does not include keepalive requests after the initial # request per connection. For example, if a child process handles # an initial request and 10 subsequent "keptalive" requests, it # would only count as 1 request towards this limit. # MaxRequestsPerChild 0 # # Listen: Allows you to bind Apache to specific IP addresses and/or # ports, in addition to the default. See also the # directive. # #Listen 3000 #Listen 12.34.56.78:80 # # BindAddress: You can support virtual hosts with this option. This directive # is used to tell the server which IP address to listen to. It can either # contain "*", an IP address, or a fully qualified Internet domain name. # See also the and Listen directives. # #BindAddress * # # Dynamic Shared Object (DSO) Support # # To be able to use the functionality of a module which was built as a DSO you # have to place corresponding `LoadModule' lines at this location so the # directives contained in it are actually available _before_ they are used. # Please read the file README.DSO in the Apache 1.3 distribution for more # details about the DSO mechanism and run `httpd -l' for the list of already # built-in (statically linked and thus always available) modules in your httpd # binary. # # Note: The order is which modules are loaded is important. Don't change # the order below without expert advice. # # Example: # LoadModule foo_module libexec/mod_foo.so # # ExtendedStatus controls whether Apache will generate "full" status # information (ExtendedStatus On) or just basic information (ExtendedStatus # Off) when the "server-status" handler is called. The default is Off. # #ExtendedStatus On ### Section 2: 'Main' server configuration # # The directives in this section set up the values used by the 'main' # server, which responds to any requests that aren't handled by a # definition. These values also provide defaults for # any containers you may define later in the file. # # All of these directives may appear inside containers, # in which case these default settings will be overridden for the # virtual host being defined. # # # If your ServerType directive (set earlier in the 'Global Environment' # section) is set to "inetd", the next few directives don't have any # effect since their settings are defined by the inetd configuration. # Skip ahead to the ServerAdmin directive. # # # Port: The port to which the standalone server listens. For # ports < 1023, you will need httpd to be run as root initially. # Port 80 # # If you wish httpd to run as a different user or group, you must run # httpd as root initially and it will switch. # # User/Group: The name (or #number) of the user/group to run httpd as. # . On SCO (ODT 3) use "User nouser" and "Group nogroup". # . On HPUX you may not be able to use shared memory as nobody, and the # suggested workaround is to create a user www and use that user. # NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET) # when the value of (unsigned)Group is above 60000; # don't use Group #-1 on these systems! # User nobody Group #-1 # # ServerAdmin: Your address, where problems with the server should be # e-mailed. This address appears on some server-generated pages, such # as error documents. # ServerAdmin you@your.address # # ServerName allows you to set a host name which is sent back to clients for # your server if it's different than the one the program would get (i.e., use # "www" instead of the host's real name). # # Note: You cannot just invent host names and hope they work. The name you # define here must be a valid DNS name for your host. If you don't understand # this, ask your network administrator. # If your host doesn't have a registered DNS name, enter its IP address here. # You will have to access it by its address (e.g., http://123.45.67.89/) # anyway, and this will make redirections work in a sensible way. # #ServerName new.host.name # # DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but # symbolic links and aliases may be used to point to other locations. # DocumentRoot "@@ServerRoot@@/htdocs" # # Each directory to which Apache has access, can be configured with respect # to which services and features are allowed and/or disabled in that # directory (and its subdirectories). # # First, we configure the "default" to be a very restrictive set of # permissions. # Options FollowSymLinks AllowOverride None # # Note that from this point forward you must specifically allow # particular features to be enabled - so if something's not working as # you might expect, make sure that you have specifically enabled it # below. # # # This should be changed to whatever you set DocumentRoot to. # # # This may also be "None", "All", or any combination of "Indexes", # "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews". # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # Options Indexes FollowSymLinks MultiViews # # This controls which options the .htaccess files in directories can # override. Can also be "All", or any combination of "Options", "FileInfo", # "AuthConfig", and "Limit" # AllowOverride None # # Controls who can get stuff from this server. # Order allow,deny Allow from all # # UserDir: The name of the directory which is appended onto a user's home # directory if a ~user request is received. # UserDir public_html # # Control access to UserDir directories. The following is an example # for a site where these directories are restricted to read-only. # # # AllowOverride FileInfo AuthConfig Limit # Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec # # Order allow,deny # Allow from all # # # Order deny,allow # Deny from all # # # # DirectoryIndex: Name of the file or files to use as a pre-written HTML # directory index. Separate multiple entries with spaces. # DirectoryIndex index.html # # AccessFileName: The name of the file to look for in each directory # for access control information. # AccessFileName .htaccess # # The following lines prevent .htaccess files from being viewed by # Web clients. Since .htaccess files often contain authorization # information, access is disallowed for security reasons. Comment # these lines out if you want Web visitors to see the contents of # .htaccess files. If you change the AccessFileName directive above, # be sure to make the corresponding changes here. # # Also, folks tend to use names such as .htpasswd for password # files, so this will protect those as well. # Order allow,deny Deny from all # # CacheNegotiatedDocs: By default, Apache sends "Pragma: no-cache" with each # document that was negotiated on the basis of content. This asks proxy # servers not to cache the document. Uncommenting the following line disables # this behavior, and proxies will be allowed to cache the documents. # #CacheNegotiatedDocs # # UseCanonicalName: (new for 1.3) With this setting turned on, whenever # Apache needs to construct a self-referencing URL (a URL that refers back # to the server the response is coming from) it will use ServerName and # Port to form a "canonical" name. With this setting off, Apache will # use the hostname:port that the client supplied, when possible. This # also affects SERVER_NAME and SERVER_PORT in CGI scripts. # UseCanonicalName On # # TypesConfig describes where the mime.types file (or equivalent) is # to be found. # TypesConfig conf/mime.types # # DefaultType is the default MIME type the server will use for a document # if it cannot otherwise determine one, such as from filename extensions. # If your server contains mostly text or HTML documents, "text/plain" is # a good value. If most of your content is binary, such as applications # or images, you may want to use "application/octet-stream" instead to # keep browsers from trying to display binary files as though they are # text. # DefaultType text/plain # # The mod_mime_magic module allows the server to use various hints from the # contents of the file itself to determine its type. The MIMEMagicFile # directive tells the module where the hint definitions are located. # mod_mime_magic is not part of the default server (you have to add # it yourself with a LoadModule [see the DSO paragraph in the 'Global # Environment' section], or recompile the server and include mod_mime_magic # as part of the configuration), so it's enclosed in an container. # This means that the MIMEMagicFile directive will only be processed if the # module is part of the server. # MIMEMagicFile conf/magic # # HostnameLookups: Log the names of clients or just their IP addresses # e.g., www.apache.org (on) or 204.62.129.132 (off). # The default is off because it'd be overall better for the net if people # had to knowingly turn this feature on, since enabling it means that # each client request will result in AT LEAST one lookup request to the # nameserver. # HostnameLookups Off # # ErrorLog: The location of the error log file. # If you do not specify an ErrorLog directive within a # container, error messages relating to that virtual host will be # logged here. If you *do* define an error logfile for a # container, that host's errors will be logged there and not here. # ErrorLog logs/error_log # # LogLevel: Control the number of messages logged to the error_log. # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. # LogLevel warn # # The following directives define some format nicknames for use with # a CustomLog directive (see below). # LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common LogFormat "%{Referer}i -> %U" referer LogFormat "%{User-agent}i" agent # # The location and format of the access logfile (Common Logfile Format). # If you do not define any access logfiles within a # container, they will be logged here. Contrariwise, if you *do* # define per- access logfiles, transactions will be # logged therein and *not* in this file. # CustomLog logs/access_log common # # If you would like to have agent and referer logfiles, uncomment the # following directives. # #CustomLog logs/referer_log referer #CustomLog logs/agent_log agent # # If you prefer a single logfile with access, agent, and referer information # (Combined Logfile Format) you can use the following directive. # #CustomLog logs/access_log combined # # Optionally add a line containing the server version and virtual host # name to server-generated pages (error documents, FTP directory listings, # mod_status and mod_info output etc., but not CGI generated documents). # Set to "EMail" to also include a mailto: link to the ServerAdmin. # Set to one of: On | Off | EMail # ServerSignature On # # Aliases: Add here as many aliases as you need (with no limit). The format is # Alias fakename realname # # Note that if you include a trailing / on fakename then the server will # require it to be present in the URL. So "/icons" isn't aliased in this # example, only "/icons/".. # Alias /icons/ "@@ServerRoot@@/icons/" Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all # # ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases, except that # documents in the realname directory are treated as applications and # run by the server when requested rather than as documents sent to the client. # The same rules about trailing "/" apply to ScriptAlias directives as to # Alias. # ScriptAlias /cgi-bin/ "@@ServerRoot@@/cgi-bin/" # # "@@ServerRoot@@/cgi-bin" should be changed to whatever your ScriptAliased # CGI directory exists, if you have that configured. # AllowOverride None Options None Order allow,deny Allow from all # # Redirect allows you to tell clients about documents which used to exist in # your server's namespace, but do not anymore. This allows you to tell the # clients where to look for the relocated document. # Format: Redirect old-URI new-URL # # # Directives controlling the display of server-generated directory listings. # # # FancyIndexing is whether you want fancy directory indexing or standard # IndexOptions FancyIndexing # # AddIcon* directives tell the server which icon to show for different # files or filename extensions. These are only displayed for # FancyIndexed directories. # AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip AddIconByType (TXT,/icons/text.gif) text/* AddIconByType (IMG,/icons/image2.gif) image/* AddIconByType (SND,/icons/sound2.gif) audio/* AddIconByType (VID,/icons/movie.gif) video/* AddIcon /icons/binary.gif .bin .exe AddIcon /icons/binhex.gif .hqx AddIcon /icons/tar.gif .tar AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip AddIcon /icons/a.gif .ps .ai .eps AddIcon /icons/layout.gif .html .shtml .htm .pdf AddIcon /icons/text.gif .txt AddIcon /icons/c.gif .c AddIcon /icons/p.gif .pl .py AddIcon /icons/f.gif .for AddIcon /icons/dvi.gif .dvi AddIcon /icons/uuencoded.gif .uu AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl AddIcon /icons/tex.gif .tex AddIcon /icons/bomb.gif core AddIcon /icons/back.gif .. AddIcon /icons/hand.right.gif README AddIcon /icons/folder.gif ^^DIRECTORY^^ AddIcon /icons/blank.gif ^^BLANKICON^^ # # DefaultIcon is which icon to show for files which do not have an icon # explicitly set. # DefaultIcon /icons/unknown.gif # # AddDescription allows you to place a short description after a file in # server-generated indexes. These are only displayed for FancyIndexed # directories. # Format: AddDescription "description" filename # #AddDescription "GZIP compressed document" .gz #AddDescription "tar archive" .tar #AddDescription "GZIP compressed tar archive" .tgz # # ReadmeName is the name of the README file the server will look for by # default, and append to directory listings. # # HeaderName is the name of a file which should be prepended to # directory indexes. # # The server will first look for name.html and include it if found. # If name.html doesn't exist, the server will then look for name.txt # and include it as plaintext if found. # ReadmeName README HeaderName HEADER # # IndexIgnore is a set of filenames which directory indexing should ignore # and not include in the listing. Shell-style wildcarding is permitted. # IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t # # AddEncoding allows you to have certain browsers (Mosaic/X 2.1+) uncompress # information on the fly. Note: Not all browsers support this. # Despite the name similarity, the following Add* directives have nothing # to do with the FancyIndexing customization directives above. # AddEncoding x-compress Z AddEncoding x-gzip gz tgz # # AddLanguage allows you to specify the language of a document. You can # then use content negotiation to give a browser a file in a language # it can understand. # # Note 1: The suffix does not have to be the same as the language # keyword --- those with documents in Polish (whose net-standard # language code is pl) may wish to use "AddLanguage pl .po" to # avoid the ambiguity with the common suffix for perl scripts. # # Note 2: The example entries below illustrate that in quite # some cases the two character 'Language' abbriviation is not # identical to the two character 'Country' code for it's country, # E.g. 'Danmark/dk' versus 'Danish/da'. # # Note 3: In the case of 'ltz' we violate the RFC by using a three char # specifier. But there is 'work in progress' to fix this and get # the reference data for rfc1766 cleaned up. # # Danish (da) - Dutch (nl) - English (en) - Estonian (ee) # French (fr) - German (de) - Greek-Modern (el) # Italian (it) -Portugese (pt) - Luxembourgeois* (ltz) # Spanish (es) - Swedish (sv) - Catalan (ca) - Czech(cz) # AddLanguage da .dk AddLanguage nl .nl AddLanguage en .en AddLanguage et .ee AddLanguage fr .fr AddLanguage de .de AddLanguage el .el AddLanguage it .it AddLanguage pt .pt AddLanguage ltz .lu AddLanguage ca .ca AddLanguage es .es AddLanguage sv .se AddLanguage cz .cz # LanguagePriority allows you to give precedence to some languages # in case of a tie during content negotiation. # # Just list the languages in decreasing order of preference. We have # more or less alphabetized them here. You probably want to change this. # LanguagePriority en da nl et fr de \ el it pt ltz ca es sv # # AddType allows you to tweak mime.types without actually editing it, or to # make certain files to be certain types. # # For example, the PHP 3.x module (not part of the Apache distribution - see # http://www.php.net) will typically use: # #AddType application/x-httpd-php3 .php3 #AddType application/x-httpd-php3-source .phps # # And for PHP 4.x, use: # #AddType application/x-httpd-php .php #AddType application/x-httpd-php-source .phps AddType application/x-tar .tgz # # AddHandler allows you to map certain file extensions to "handlers", # actions unrelated to filetype. These can be either built into the server # or added with the Action command (see below) # # If you want to use server side includes, or CGI outside # ScriptAliased directories, uncomment the following lines. # # To use CGI scripts: # #AddHandler cgi-script .cgi # # To use server-parsed HTML files # #AddType text/html .shtml #AddHandler server-parsed .shtml # # Uncomment the following line to enable Apache's send-asis HTTP file # feature # #AddHandler send-as-is asis # # If you wish to use server-parsed imagemap files, use # #AddHandler imap-file map # # To enable type maps, you might want to use # #AddHandler type-map var # # Action lets you define media types that will execute a script whenever # a matching file is called. This eliminates the need for repeated URL # pathnames for oft-used CGI file processors. # Format: Action media/type /cgi-script/location # Format: Action handler-name /cgi-script/location # # # MetaDir: specifies the name of the directory in which Apache can find # meta information files. These files contain additional HTTP headers # to include when sending the document # #MetaDir .web # # MetaSuffix: specifies the file name suffix for the file containing the # meta information. # #MetaSuffix .meta # # Customizable error response (Apache style) # these come in three flavors # # 1) plain text #ErrorDocument 500 "The server made a boo boo. # n.b. the (") marks it as text, it does not get output # # 2) local redirects #ErrorDocument 404 /missing.html # to redirect to local URL /missing.html #ErrorDocument 404 /cgi-bin/missing_handler.pl # N.B.: You can redirect to a script or a document using server-side-includes. # # 3) external redirects #ErrorDocument 402 http://some.other_server.com/subscription_info.html # N.B.: Many of the environment variables associated with the original # request will *not* be available to such a script. # # The following directives modify normal HTTP response behavior. # The first directive disables keepalive for Netscape 2.x and browsers that # spoof it. There are known problems with these browser implementations. # The second directive is for Microsoft Internet Explorer 4.0b2 # which has a broken HTTP/1.1 implementation and does not properly # support keepalive when it is used on 301 or 302 (redirect) responses. # BrowserMatch "Mozilla/2" nokeepalive BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0 # # The following directive disables HTTP/1.1 responses to browsers which # are in violation of the HTTP/1.0 spec by not being able to grok a # basic 1.1 response. # BrowserMatch "RealPlayer 4\.0" force-response-1.0 BrowserMatch "Java/1\.0" force-response-1.0 BrowserMatch "JDK/1\.0" force-response-1.0 # # Allow server status reports, with the URL of http://servername/server-status # Change the ".your_domain.com" to match your domain to enable. # # # SetHandler server-status # Order deny,allow # Deny from all # Allow from .your_domain.com # # # Allow remote server configuration reports, with the URL of # http://servername/server-info (requires that mod_info.c be loaded). # Change the ".your_domain.com" to match your domain to enable. # # # SetHandler server-info # Order deny,allow # Deny from all # Allow from .your_domain.com # # # There have been reports of people trying to abuse an old bug from pre-1.1 # days. This bug involved a CGI script distributed as a part of Apache. # By uncommenting these lines you can redirect these attacks to a logging # script on phf.apache.org. Or, you can record them yourself, using the script # support/phf_abuse_log.cgi. # # # Deny from all # ErrorDocument 403 http://phf.apache.org/phf_abuse_log.cgi # # # Proxy Server directives. Uncomment the following lines to # enable the proxy server: # # #ProxyRequests On # # # Order deny,allow # Deny from all # Allow from .your_domain.com # # # Enable/disable the handling of HTTP/1.1 "Via:" headers. # ("Full" adds the server version; "Block" removes all outgoing Via: headers) # Set to one of: Off | On | Full | Block # #ProxyVia On # # To enable the cache as well, edit and uncomment the following lines: # (no cacheing without CacheRoot) # #CacheRoot "@@ServerRoot@@/proxy" #CacheSize 5 #CacheGcInterval 4 #CacheMaxExpire 24 #CacheLastModifiedFactor 0.1 #CacheDefaultExpire 1 #NoCache a_domain.com another_domain.edu joes.garage_sale.com # # End of proxy directives. ### Section 3: Virtual Hosts # # VirtualHost: If you want to maintain multiple domains/hostnames on your # machine you can setup VirtualHost containers for them. # Please see the documentation at # for further details before you try to setup virtual hosts. # You may use the command line option '-S' to verify your virtual host # configuration. # # If you want to use name-based virtual hosts you need to define at # least one IP address (and port number) for them. # #NameVirtualHost 12.34.56.78:80 #NameVirtualHost 12.34.56.78 # # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # # # ServerAdmin webmaster@host.some_domain.com # DocumentRoot /www/docs/host.some_domain.com # ServerName host.some_domain.com # ErrorLog logs/host.some_domain.com-error_log # CustomLog logs/host.some_domain.com-access_log common # # # Apache-Admin-Config-0.94/t/isin.t0000644000175000000620000000072507500156421016222 0ustar rsstaff00000000000000use strict; use Test; plan test => 9; use Apache::Admin::Config; my $conf = new Apache::Admin::Config; my $sec1 = $conf->add_section(test=>1); ok(defined $sec1); my $sec2 = $sec1->add_section(test=>2); ok(defined $sec2); my $sec3 = $sec2->add_section(test=>2); ok(defined $sec3); ok($sec1->isin($conf)); ok(!$sec2->isin($conf)); ok(!$sec3->isin($conf)); ok($sec1->isin($conf, '-recursif')); ok($sec2->isin($conf, '-recursif')); ok($sec3->isin($conf, '-recursif')); Apache-Admin-Config-0.94/t/directive_insert.t0000644000175000000620000000141707500156421020621 0ustar rsstaff00000000000000use strict; use Test; plan test => 20; use Apache::Admin::Config; ok(1); my $conf = new Apache::Admin::Config; ok(defined $conf); my $rv = $conf->add_directive('test', '-ontop'); ok(defined $rv); ok($rv->name, 'test'); ok($rv->first_line, 1); my $rv2 = $conf->add_directive('test2', '-ontop'); ok(defined $rv2); ok($rv2->name, 'test2'); ok($rv2->first_line, 1); ok($rv->first_line, 2); my $rv3 = $conf->add_directive('test3', '-onbottom'); ok(defined $rv3); ok($rv3->name, 'test3'); ok($rv3->first_line, 3); ok($rv2->first_line, 1); ok($rv->first_line, 2); my $rv4 = $conf->add_directive('test4', -after=>$conf->directive('test2')); ok(defined $rv4); ok($rv4->name, 'test4'); ok($rv4->first_line, 2); ok($rv3->first_line, 4); ok($rv2->first_line, 1); ok($rv->first_line, 3); Apache-Admin-Config-0.94/t/comment_delete.t0000644000175000000620000000073207500156451020245 0ustar rsstaff00000000000000use strict; use Test; plan test => 5; use Apache::Admin::Config; ok(1); my $conf = new Apache::Admin::Config; ok(defined $conf); $conf->add_comment('test1'); $conf->add_comment('test2'); $conf->add_comment('test3'); $conf->add_comment('test4'); $conf->add_comment('test5'); $conf->add_comment('test6'); ok($conf->comment('test3')->first_line, 3); ok($conf->comment('test4')->first_line, 4); $conf->comment('test3')->delete; ok($conf->comment('test4')->first_line, 3); Apache-Admin-Config-0.94/t/section_delete.t0000644000175000000620000000073307500156421020245 0ustar rsstaff00000000000000use strict; use Test; plan test => 5; use Apache::Admin::Config; ok(1); my $conf = new Apache::Admin::Config; ok(defined $conf); $conf->add_section(test=>1); $conf->add_section(test=>2); $conf->add_section(test=>3); $conf->add_section(test=>4); $conf->add_section(test=>5); $conf->add_section(test2=>6); ok($conf->section(test=>3)->first_line, 5); ok($conf->section(test=>4)->first_line, 7); $conf->section(test=>3)->delete; ok($conf->section(test=>4)->first_line, 5); Apache-Admin-Config-0.94/t/section_insert.t0000644000175000000620000000141107500156421020301 0ustar rsstaff00000000000000use strict; use Test; plan test => 20; use Apache::Admin::Config; ok(1); my $conf = new Apache::Admin::Config; ok(defined $conf); my $rv = $conf->add_section(test=>1, '-ontop'); ok(defined $rv); ok($rv->name, 'test'); ok($rv->first_line, 1); my $rv2 = $conf->add_section(test2=>2, '-ontop'); ok(defined $rv2); ok($rv2->name, 'test2'); ok($rv2->first_line, 1); ok($rv->first_line, 3); my $rv3 = $conf->add_section(test3=>3, '-onbottom'); ok(defined $rv3); ok($rv3->name, 'test3'); ok($rv3->first_line, 5); ok($rv2->first_line, 1); ok($rv->first_line, 3); my $rv4 = $conf->add_section(test4=>4, -after=>$conf->section(test2=>2)); ok(defined $rv4); ok($rv4->name, 'test4'); ok($rv4->first_line, 3); ok($rv3->first_line, 7); ok($rv2->first_line, 1); ok($rv->first_line, 5); Apache-Admin-Config-0.94/t/directive.t0000644000175000000620000000060107523432406017234 0ustar rsstaff00000000000000use strict; use Test; plan test => 6; use Apache::Admin::Config; ok(1); my $apache = new Apache::Admin::Config ('t/httpd.conf-dist'); ok(defined $apache); my @dirlist = $apache->directive; ok(@dirlist, 88); my @dirvals = $apache->directive('browsermatch'); ok(@dirvals, 5); @dirvals = $apache->directive('BrowSerMatch'); ok(@dirvals, 5); my $obj = $dirvals[0]; ok(defined $obj); Apache-Admin-Config-0.94/t/comment.t0000644000175000000620000000051307565310407016724 0ustar rsstaff00000000000000use strict; use Test; plan test => 5; use Apache::Admin::Config; ok(1); my $apache = new Apache::Admin::Config ('t/httpd.conf-dist'); ok(defined $apache); my @list = $apache->comment; ok(@list, 85); my $sec = $apache->section(-which=>1); ok(defined $sec); my $comment = $sec->comment(-which=>0); ok($comment->first_line, 304); Apache-Admin-Config-0.94/t/section.t0000644000175000000620000000066507523432406016734 0ustar rsstaff00000000000000use strict; use Test; plan test => 7; use Apache::Admin::Config; ok(1); my $apache = new Apache::Admin::Config ('t/httpd.conf-dist'); ok(defined $apache); my @seclist = $apache->section; ok(@seclist, 6); my @secvals = $apache->section('directory'); ok(@secvals, 4); @secvals = $apache->section('DirectorY'); ok(@secvals, 4); my $obj = $secvals[0]; ok(defined $obj); my $root = $apache->section(directory=>'/'); ok(defined $root); Apache-Admin-Config-0.94/t/value.t0000644000175000000620000000133207514533223016373 0ustar rsstaff00000000000000use strict; use Test; plan test => 40; use Apache::Admin::Config; ok(1); my $conf = new Apache::Admin::Config; foreach my $type (qw(section directive comment)) { my $item = $conf->add($type, test=>"test"); ok(defined $item); ok($item eq 'test'); ok($item ne 'tset'); $item->value(40); ok($item == 40); ok($item != 20); $item->value('test'); ok($item->value eq 'test'); my $item2 = $conf->select($type, -value=>'test'); ok(defined $item2); ok($item2 eq 'test'); ok($item2->value eq 'test'); $item2->set_value('test_change'); ok($item2 eq 'test_change'); ok($item2->value eq 'test_change'); ok($item eq 'test_change'); ok($item->value eq 'test_change'); } Apache-Admin-Config-0.94/t/directive_delete.t0000644000175000000620000000075707500156421020565 0ustar rsstaff00000000000000use strict; use Test; plan test => 5; use Apache::Admin::Config; ok(1); my $conf = new Apache::Admin::Config; ok(defined $conf); $conf->add_directive(test=>1); $conf->add_directive(test=>2); $conf->add_directive(test=>3); $conf->add_directive(test=>4); $conf->add_directive(test=>5); $conf->add_directive(test2=>6); ok($conf->directive(test=>3)->first_line, 3); ok($conf->directive(test=>4)->first_line, 4); $conf->directive(test=>3)->delete; ok($conf->directive(test=>4)->first_line, 3); Apache-Admin-Config-0.94/t/save.t0000644000175000000620000000044307523625521016222 0ustar rsstaff00000000000000use strict; use Test; plan test => 886; use Apache::Admin::Config; ok(1); my $conf = new Apache::Admin::Config 't/httpd.conf-dist'; open(CONF, 't/httpd.conf-dist'); my @conf = split(/\n/, $conf->dump_raw); my $i = 0; while() { chomp; ok($_ eq $conf[$i++]); } close(CONF); Apache-Admin-Config-0.94/t/handle.t0000644000175000000620000000201207614364017016512 0ustar rsstaff00000000000000use strict; use Test; plan test => 14; use Apache::Admin::Config; ok(1); open(HTTPD_CONF, 't/httpd.conf-dist'); ok(fileno HTTPD_CONF); my $apache = new Apache::Admin::Config (\*HTTPD_CONF); ok(defined $apache); my @dirlist = $apache->directive; ok(@dirlist, 88); my @dirvals = $apache->directive('browsermatch'); ok(@dirvals, 5); my $obj = $dirvals[0]; ok(defined $obj); open(HTTPD_TMP, "+>/tmp/httpd.conf-$$-aac"); ok(fileno HTTPD_TMP); ok($apache->save(\*HTTPD_TMP)); close(HTTPD_TMP); open(HTTPD_TMP, "+directive; ok(@dirlist, 88); my $rv = $apache->add_directive(test=>'bla'); ok($rv->value, 'bla'); ok($apache->save()); close(HTTPD_TMP); open(HTTPD_TMP, "+directive; ok(@dirlist, 89); unlink("/tmp/httpd.conf-$$-aac"); close(HTTPD_TMP); close(HTTPD_CONF); Apache-Admin-Config-0.94/t/comment_insert.t0000644000175000000620000000141107500156451020302 0ustar rsstaff00000000000000use strict; use Test; plan test => 20; use Apache::Admin::Config; ok(1); my $conf = new Apache::Admin::Config; ok(defined $conf); my $rv = $conf->add_comment('test', '-ontop'); ok(defined $rv); ok($rv->value, 'test'); ok($rv->first_line, 1); my $rv2 = $conf->add_comment('test2', '-ontop'); ok(defined $rv2); ok($rv2->value, 'test2'); ok($rv2->first_line, 1); ok($rv->first_line, 2); my $rv3 = $conf->add_comment('test3', '-onbottom'); ok(defined $rv3); ok($rv3->value, 'test3'); ok($rv3->first_line, 3); ok($rv2->first_line, 1); ok($rv->first_line, 2); my $rv4 = $conf->add_comment('test4', -after=>$conf->comment('test2')); ok(defined $rv4); ok($rv4->value, 'test4'); ok($rv4->first_line, 2); ok($rv3->first_line, 4); ok($rv2->first_line, 1); ok($rv->first_line, 3); Apache-Admin-Config-0.94/Changes0000644000175000000620000001645310440611766016135 0ustar rsstaff000000000000002006-04-11 Daniel Muey * Release 0.93 * Fixed bug 18792 (http://rt.cpan.org/Public/Bug/Display.html?id=18792) * Updated version in README from 0.91 to 0.93 2004-12-08 Olivier Poitrey * Release 0.92 * Fix CPAN case #8782: destroy() method doesn't a true value on succesfully deleting empty sections 2003-01-25 Olivier Poitrey * Release 0.91 * Change the name() accessor behavior. Instead of returning the directive and section's name in lowercase, it no longer alter the case. Be careful, this change may broke your programs * Add some notice in the doc about the misunderstanding of the use of file handle with this module. 2002-11-15 Olivier Poitrey * Release 0.90 * Feed documentation * Add dump_reformat() method * Rewrite write_() methods to allow to change theirs contents via set_write_() methods. * Replace the "top" property by a dynamic top-level discovery engine. * Change add() method to accept an already formed item in argument instead of its description (type, name, value). * Implement clone(), copy() and move() methods * Rewrite of delete(), remove() and destroy() methods * Add internal _add_child() method and implement it in _insert_*(), add() and clone() methods * Fix select() method, now allow to search items of different types with (for example) same names * Add -create option to constructor * Add -reformat option to save() method * Add write_blank() method * Add some example scripts into the eg/ folder * Add comment grouping feature which allow consecutive comment lines to be grouped in a single comment item * Add blank lines grouping, same as comment grouping for blank lines * Fix first_line and last_line methods * Add count_lines method * Rename remove method to unlink() * Turn this project in pre-stable state 2002-08-26 Olivier Poitrey * Release 0.56 * Fix major bug in _get_index() method. Impact delete() method. Thanks to Scott Beck 2002-08-11 Olivier Poitrey * Release 0.55 * Rewrite line continuation mechanism 2002-08-15 Olivier Poitrey * Release O.54 * Fix a major bug in save method (thanks to Szilveszter Farkas) * Rename some internal variables 2002-07-15 Olivier Poitrey * Release 0.53 * Fix saveas() method 2002-06-07 Olivier Poitrey * Release 0.52 * Fix big memory leak problem (thanks to Scott Beck) * Fix miscellaneous bugs 2002-06-07 Olivier Poitrey * Release 0.51 * Fix select() method 2002-06-07 Olivier Poitrey * Release 0.50 * Fix many major bugs * Rewrite entire module with a new algorithm * Homogenization of API (may distrub you old applications !) * Change no longer support old API (-oldapi option) * Change all methods are overloaded to return its value. Using overloading feature *is now really deprecated* * New support for indentation * New handle comment and blank lines * New methods : add, select, add_comment, comment, add_blank and blank * Upgrade documentation * Optimizations it's now very fast ! =) 2002-06-03 Olivier Poitrey * Release 0.21 Mon Jun 3 16:39:41 2002 * Fix major bugs. Correction of '-ontop', '-onbottom', '-after' and '-before' parameters behavior in 'add_directive' and 'add_section' methods. 2002-06-03 Olivier Poitrey * Release 0.20 * Fix major bugs * Rethink completely the algorithm, it's 65 times faster ! 2002-04-11 Olivier Poitrey * Release 0.16 * Fix major bug, no longer merging namespace of identical (same name/value) sections 2001-12-11 Olivier Poitrey * Release 0.15 * Fix minor bug, add_(section|directive) with option -onbottom weren't work properly * Add dump_raw() method 2001-12-08 Olivier Poitrey * Release 0.14 Sat Dec 8 14:14:50 2001 * Fix major bug that cause an endless loop in the constructor with perl 5.005 and maybe 5.6 * Fix error messages 2001-12-06 Olivier Poitrey * Release 0.13 * Fix compatibility problem with perl 5.005, thinks to Anton Berezin * Fix error when add_(directive|section) on an empty file 2001-11-11 Olivier Poitrey * Release 0.12 * New feature, constructor and save() method now accept file handle instead of file path. Thanks Peter Suschlik for his patch. 2001-10-25 Olivier Poitrey * Release 0.11 * Fix bug in add_section method. add_section will add entries before the last context's section line. 2001-10-12 Olivier Poitrey * Release 0.10 * Fix bug in test scripts, that makes test fail randomly * Change directive() now returns full list of directives, sorted as it comes in the file. Each element of this list is an object that points to the directive entry. * Change directive(Foo) also returns a full list of value of all "Foo" directive in current context, also sorted as it comes in the file. Each list's element is also an object that points to the directive entry. * Change directive(Foo, Bar) returns an object that points to the last directive (if more than one) wich has the same directive's name/value. In list context, it returns the full list of same directive's name/value. * Change directive() can now takes the -which=>N parameter to select the entry's number to return (if exists). * Change directive() can now takes 4 new type of parameters: -before, -after, -ontop and -onbottom. * Modification of parser to allow sections to have same name than directive in the same context without clash. * New methods (see documentation for more details) first_line, last_line, lines, dump_line, isin, type and name. * Change API, so contructor can take the -oldapi=>1 argument for a backward compatibility 2001-09-20 Olivier Poitrey * Release 0.07 * Change, section and directive methods no any longer return an arrayref in list context but a simple list. Documentation corrected (thanx to Nathan Wiger for this suggestion). 2001-09-18 Olivier Poitrey * Release 0.6 * Add a quick and dirty documentation * Change value() method, returns the context value if no arguments given * Change new() method, can be called without argument, save() need an argument in this case 2001-08-18 Olivier Poitrey * Release 0.05 * Fix major bug, if config file wasn't exists, module won't work ! * Fix bug, value() method wasn't took the appropriate value to change it, resulting to an unchanged value * Fix bug, $master and $root value was undefined in value method, so value wasn't work at all 2001-08-17 Olivier Poitrey * Release 0.4 * Fix a minor bug in directive method. 2001-08-17 Olivier Poitrey * Release 0.03 * Fix a major bug in directive method. 2001-08-16 Olivier Poitrey * Release 0.02 * Put module on CPAN * Fix a very major bug that cause "syntax error" from parser on directives with no value like "clearmodulelist", thanx A2 for this report. 2001-08-12 Olivier Poitrey * Release 0.01 * Original version Apache-Admin-Config-0.94/MANIFEST0000644000175000000620000000056010155610017015752 0ustar rsstaff00000000000000lib/Apache/Admin/Config.pm Changes Makefile.PL MANIFEST README UPGRADE-0.10 t/comment.t t/comment_delete.t t/comment_insert.t t/directive.t t/directive_delete.t t/directive_insert.t t/handle.t t/httpd.conf-dist t/isin.t t/section.t t/section_delete.t t/section_insert.t t/save.t t/value.t META.yml Module meta-data (added by MakeMaker) Apache-Admin-Config-0.94/lib/0000755000175000000620000000000010440613077015374 5ustar rsstaff00000000000000Apache-Admin-Config-0.94/lib/Apache/0000755000175000000620000000000010440613077016555 5ustar rsstaff00000000000000Apache-Admin-Config-0.94/lib/Apache/Admin/0000755000175000000620000000000010440613077017605 5ustar rsstaff00000000000000Apache-Admin-Config-0.94/lib/Apache/Admin/Config.pm0000644000175000000620000012024310440611766021355 0ustar rsstaff00000000000000package Apache::Admin::Config; use 5.005; use strict; use FileHandle; $Apache::Admin::Config::VERSION = '0.94'; $Apache::Admin::Config::DEBUG = 0; =pod =head1 NAME Apache::Admin::Config - A module to read/write Apache like configuration files =head1 SYNOPSIS use Apache::Admin::Config; # Parse an apache configuration file my $conf = new Apache::Admin::Config "/path/to/config_file.conf" or die $Apache::Admin::Config::ERROR; my $directive = $conf->directive('documentroot'); print $directive->name; # "documentroot" print $directive->value; # "/my/document/root" print $directive->type; # "directive" $directive->isin($conf); # true $directive->delete; # print the directive list foreach($conf->directive()) { print $_->name, "\n"; } # print the virtualhost list print $_->section('servername')->value(), "\n" foreach $conf->section(-name => "virtualhost"); # add a directive in all virtualhosts foreach($conf->section(-name => "virtualhost")) { $_->add_directive(php_admin_value => 'open_basedir "/path"'); } # Deleting all "AddType" directives $_->delete for $conf->directive("AddType"); # saving changes in place $conf->save; =head1 DESCRIPTION C provides an object oriented interface for reading and writing Apache-like configuration files without affecting comments, indentation, or truncated lines. You can easily extract informations from the apache configuration, or manage htaccess files. I wrote this class because I work for an IPP, and we often manipulate apache configuration files for adding new clients, activate some features or un/locking directories using htaccess, etc. It can also be useful for writing some one-shoot migrations scripts in few lines. =head1 METHODES =head2 new $obj = new Apache::Admin::Config [/path/to/file|handle], [-indent => $integer], ['-create'], ['-no-comment-grouping'], ['-no-blank-grouping'] Create or read, if given in argument, an apache like configuration file, and return an Apache::Admin::Config instence. Arguments: =over 4 =item I> Path to the configuration file to parse. If none given, create a new one. =item I> Instead of specify a path to a file, you can give a reference to an handle that point to an already openned file. You can do this like this : my $obj = new Apache::Admin::Config (\*MYHANDLE); =item I> =E I<$integer> If greater than 0, activates the indentation on added lines, the integer tell how many spaces you went per level of indentation (suggest 4). A negative value means padding with tabulation(s). =item I> If present and path to an unexisting file is given, don't return an error. =item I> When there are several successive comment-lines, if comment grouping is enabled only one comment item is created. If present, disable comment grouping at parsing time. Enabled by default. =item I> Same as comment grouping but for blank lines. =back =cut # We wrap the whole module part because we manipulate a tree with # circular references. Because of the way perl's garbage collector # works, we have to isolate circular reference in another package to # be able to destroy circular reference before the garbage collector # try to destroy the tree. Without this mechanism, the DESTROY event # will never be called. sub new { my $proto = shift; my $class = ref $proto || $proto; my $self = {}; bless $self, $class; my $htaccess = shift; my $tree = $self->{tree} = new Apache::Admin::Config::Tree(@_) or return; if(defined $htaccess) { $tree->_load($htaccess) || return undef; } else # if htaccess doesn't exists, init new one { $tree->_init || return undef; } return $self; } =pod =head2 save $obj->save(['/path/to/file'|HANDLE], ['-reformat']) Write modifications to the configuration file. If a path to a file is given, save the modification to this file instead. You also can give a reference to a filehandle like this : $conf->save(\*MYHANDLE) or die($conf->error()); Note: If you invoke save() on an object instantiated with a filehandle, you should emptied it before. Keep in mind that the constructor don't seek the FH to the begin neither before nor after reading it. =cut sub save { my $reformat = Apache::Admin::Config::Tree::_get_arg(\@_, '-reformat!'); my($self, $saveas) = @_; my $htaccess = defined $saveas ? $saveas : $self->{tree}->{htaccess}; return $self->_set_error("you have to specify a location for writing configuration") unless defined $htaccess; my $fh; if(ref $htaccess eq 'GLOB') { $fh = $htaccess; } else { $fh = new FileHandle(">$htaccess") or return $self->_set_error("can't open `$htaccess' file for read"); } print $fh $reformat ? $self->dump_reformat : $self->dump_raw; return 1; } sub AUTOLOAD { # redirect all method to the right package my $self = shift; my($func) = $Apache::Admin::Config::AUTOLOAD =~ /[^:]+$/g; return $self->{tree}->$func(@_); } sub DESTROY { shift->{tree}->destroy; } package Apache::Admin::Config::Tree; use strict; use Carp; use FileHandle; use overload nomethod => \&to_string; sub new { my $proto = shift; my $class = ref $proto || $proto; my $self = {}; bless($self, $class); $self->{indent} = _get_arg(\@_, '-indent'); $self->{create} = _get_arg(\@_, '-create!'); $self->{'comment-grouping'} = ! _get_arg(\@_, '-no-comment-grouping!'); $self->{'blank-grouping'} = ! _get_arg(\@_, '-no-blank-grouping!'); # init the tree $self->{type} = 'section'; $self->{parent} = undef; $self->{children} = []; return($self); } =pod =head2 dump_raw $obj->dump_raw Returns the configuration file as same as it will be if it was saved in a file with the B method. If you don't call this method from the top level section, it returns the part of the configuration file that is under the object's context. =cut sub dump_raw { my($self) = @_; return join '', $self->{raw}||'', $self->_deploy(), $self->{raw2}||''; } =pod =head2 dump_reformat $obj->dump_raw Same as dump_raw(), but reformat each line. Usefull used with -indent constructor parameter. =cut sub dump_reformat { my($self) = @_; my $string = ''; foreach($self->select()) { if($_->type eq 'section') { $string .= $self->write_section($_->name, $_->value); $string .= $_->dump_reformat(); $string .= $self->write_section_closing($_->name); } else { # is it perl 5.0004 compatible ?? my $method = "write_".$_->type; my $name; if($_->type eq 'directive') { $name = $_->name; } elsif($_->type eq 'comment') { $name = $_->value; } elsif($_->type eq 'blank') { $name = $_->{length}; } my $value = defined $_->value ? $_->value : ''; $string .= $self->$method($name||'', $value); } } return $string; } =pod =head2 select @result = $obj->select ( [-type => $type], [-name => $name], [-value => $value], [-which => $index], ); @directives = $obj->select('directive'); @sections_foo = $obj->select('section', 'Foo'); This method search in the current context for items (directives, sections, comments...) that correspond to a properties given by arguments. It returns a B of matched nods. This method can only be called on an object of type "section". This method search only for elements in the section pointed by object, and isn't recursive. So elements B sub-sections of current section aren's seek (it's not a bug). Arguments: =over 4 =item B> Selects item(s) of C type. =item B> Selects item(s) with C name. =item B> Selects item(s) with C value. =item B> Instead of returning a list of items, returns only a single one pointed by index given to the -which option. Caution, returns an empty string if none selected, so don't cascade your methodes calls like $obj->select(-which=>0)->name. Index starts at 0. =back Method returns a list of item(s) founds. Each items is an Apache::Admin::Config object with same methods but pointing to a different part of the tree. =cut sub select { my $self = shift; my $which = _get_arg(\@_, '-which'); my %args; $args{type} = _get_arg(\@_, '-type') || undef; $args{name} = _get_arg(\@_, '-name') || undef; $args{value} = _get_arg(\@_, '-value') || undef; # accepting old style arguments for backward compatibilitie $args{type} = shift unless defined $args{type}; $args{name} = shift unless defined $args{name}; $args{value} = shift unless defined $args{value}; # _get_arg return undef on error or empty string on not founded rule return $self->_set_error('malformed arguments') if not defined $which; # $which isn't an integer return $self->_set_error('error in -which argument: not an integer') if $which =~ /[^\d\-]/; return $self->_set_error('too many arguments') if @_; return $self->_set_error('method not allowed') unless $self->{type} eq 'section'; $args{name} = lc($args{name}) if defined $args{name}; $args{value} = lc($args{value}) if defined $args{value}; my @children = @{$self->{children}}; my $n = 0; my @items; # pre-select fields to test on each objects my @field_to_test = grep(defined $args{$_}, qw(type name value)); foreach my $item (@children) { my $match = 1; # for all given arguments, we test if it matched # for missing aguments, match is always true foreach(@field_to_test) { if(defined $item->{$_}) { $match = $args{$_} eq lc($item->{$_}); } else { $match = 0; } last unless $match; } if($match) { push(@items, $item); } } if(length $which) { return defined overload::StrVal($items[$which]) ? $items[$which] : ''; } else { # We don't return just @items but transfort it in a list # because in scalar context, returning an array is same as # returning the number of ellements in it, but we want return # the _last_ element like a list do une scalar context. If you # have a better/nicer idea... return(@items ? @items[0 .. $#items] : ()); } } =pod =head2 directive @directives = $obj->directive(args...) Same as calling select('directive', args...) =cut sub directive { my $self = shift; $self->select('directive', @_); } =pod =head2 section @sections = $obj->section(args...) Same as calling select('section', args...) =cut sub section { my $self = shift; $self->select('section', @_); } =pod =head2 comment @comments = $obj->comment(args...) Same as calling select('comment', args...) =cut sub comment { my $self = shift; $self->select('comment', undef, @_); } =pod =head2 blank @blanks = $obj->blank(args...) Same as calling select('blank', args...) =cut sub blank { my $self = shift; $self->select('blank', @_); } sub indent { my($self) = @_; my $parent = $self->parent; my $level = 0; my $indent = $self->top->{indent} || 0; while(defined $parent) { $parent = $parent->parent; $level++; } return($level ? (($indent > 0 ? ' ' : "\t") x (abs $indent)) x $level : ''); } =pod =head2 set_write_directive $conf->set_write_directive($code); Replace the directive writing engine by you own code. Code is call for adding new directives, or when you tell Apache::Admin::Config to reformat the whole configuration file. See B and B methods for more details. Your handler receives 3 arguments : $self, $name and $value. You can call the C method to get the number of spaces to put before the current line (see B methods for more details) $conf->set_write_directive(sub { my($self, $name, $value) = @_; return $self->indent . "$name $value\n"; } =cut sub write_directive { my($self) = @_; my $code = $self->_get_var('_write_directive') || \&default_write_directive; &$code(@_); } sub set_write_directive { my($self, $code) = @_; $self->{_write_directive} = $code; } sub default_write_directive { my($self, $name, $value) = @_; return undef unless defined $name; $value = defined $value ? $value : ''; return($self->indent."$name $value\n"); } =pod =head2 set_write_section $conf->set_write_section($code); Same as set_write_directive() but for section. Your handler receives 3 arguments: $self, $name and $value. You can call the C method to get the number of spaces to put before the current line (see B methods for more details) $conf->set_write_section(sub { my($self, $name, $value) = @_; return $self->indent . "<$name $value>\n"; } =cut sub write_section { my($self) = @_; my $code = $self->_get_var('_write_section') || \&default_write_section; &$code(@_); } sub set_write_section { my($self, $code) = @_; $self->{_write_section} = $code; } sub default_write_section { my($self, $name, $value) = @_; return($self->indent."<$name $value>\n"); } =pod =head2 set_write_section_closing $conf->set_write_section_closing($code); Same as set_write_directive() but for end of sections. Your handler receives 2 arguments: $self and $name. You can call the C method to get the number of spaces to put before the current line (see B methods for more details) $conf->set_write_section_closing(sub { my($self, $name) = @_; return $self->indent . "\n"; } =cut sub write_section_closing { my($self) = @_; my $code = $self->_get_var('_write_section_closing') || \&default_write_section_closing; &$code(@_); } sub set_write_section_closing { my($self, $code) = @_; $self->{_write_section_closing} = $code; } sub default_write_section_closing { my($self, $name) = @_; return($self->indent."\n"); } =pod =head2 set_write_comment $conf->set_write_comment($code); Same as set_write_directive() but for comments. Your handler receives 2 arguments: $self and $value. You can call the C method to get the number of spaces to put before the current line (see B methods for more details) $conf->set_write_comment(sub { my($self, $value) = @_; # handle comment grouping $value =~ s/\n/\n# /g; return $self->indent . join('#', split(/\n/, $value)); } =cut sub write_comment { my($self) = @_; my $code = $self->_get_var('_write_comment') || \&default_write_comment; &$code(@_); } sub set_write_comment { my($self, $code) = @_; $self->{_write_comment} = $code; } sub default_write_comment { my($self, $value) = @_; $value =~ s/\n/\n# /g; return $self->indent."# $value\n"; } =pod =head2 set_write_blank $conf->set_write_blank($code); Same as set_write_directive() but for blank lines. Your handler receives 2 arguments: $self and $number. $conf->set_write_blank(sub { my($self, $number) = @_; return $number x "\n"; } =cut sub write_blank { my($self) = @_; my $code = $self->_get_var('_write_blank') || \&default_write_blank; &$code(@_); } sub set_write_blank { my($self, $code) = @_; $self->{_write_blank} = $code; } sub default_write_blank { my($self, $number) = @_; return "\n" x $number; } =pod =head2 add $item = $obj->add ( $type|$item, [$name], [$value], [-before => $target | -after => $target | '-ontop' | '-onbottom'] ); $item = $obj->add('section', foo => 'bar', -after => $conf_item_object); $item = $obj->add('comment', 'a simple comment', '-ontop'); Add a line of type I<$type> with name I and value I in the context pointed by B<$object>. Aguments: =over 4 =item B> Type of object to add (directive, section, comment or blank). =item B> Only relevant for directives and sections. =item B> For directive and section, it defines the value, for comments it defined the text. =item B> =E I Inserts item one line before I. I _have_ to be in the same context =item B> =E I Inserts item one line after I. I _have_ to be in the same context =item B> Insert item on the fist line of current context; =item B> Iinsert item on the last line of current context; =back Returns the added item =cut sub add { my $self = shift; my($target, $where) = _get_arg(\@_, '-before|-after|-ontop!|-onbottom!'); $target = $target->{tree} if ref $target eq 'Apache::Admin::Config'; # _get_arg return undef on error or empty string on not founded rule return($self->_set_error('malformed arguments')) if(not defined $target); return($self->_set_error('too many arguments')) if(@_ > 3); my($type, $name, $value) = @_; return($self->_set_error('wrong type for destination')) unless($self->{type} eq 'section'); $where = defined $where ? $where : '-onbottom'; # default behavior if(($where eq '-before' || $where eq '-after') && defined $target) { return $self->_set_error("target `$target' isn\'t an object") unless ref $target && $target->isa('Apache::Admin::Config::Tree'); return $self->_set_error('invalid target context') unless $target->isin($self); } my $index; if($where eq '-before') { $index = $target->_get_index; } elsif($where eq '-after') { $index = $target->_get_index + 1; } elsif($where eq '-ontop') { $index = 0; } elsif($where eq '-onbottom' || $where eq '') { $index = -1; } else { return $self->_set_error('malformed arguments'); } my $item; if(ref $type) { $item = $type; $self->_add_child($item, $index); } elsif($type eq 'section') { return $self->_set_error('to few arguments') unless(defined $name and defined $value); my $raw = $self->write_section($name, $value); my $length = () = $raw =~ /\n/g; $item = $self->_insert_section($name, $value, $raw, $length, $index); $item->{raw2} = $self->write_section_closing($name); $item->{length2} = () = $item->{raw2} =~ /\n/g; } elsif($type eq 'directive') { return $self->_set_error('to few arguments') unless(defined $name); my $raw = $self->write_directive($name, $value); my $length = () = $raw =~ /\n/g; $item = $self->_insert_directive($name, $value, $raw, $length, $index); } elsif($type eq 'comment') { # $name contents value here return $self->_set_error('to few arguments') unless(defined $name); my $group = defined $value && $value ? 1 : 0; $item = $self->_insert_comment($name, $self->write_comment($name), $index, $group); } elsif($type eq 'blank') { # enabled by default my $group = defined $name ? ($name ? 1 : 0) : 1; $item = $self->_insert_blank($self->write_blank(1), $index, $group); } else { return $self->_set_error("invalid type `$type'"); } return $item; } =pod =head2 add_section $section = $obj->add_section($name, $value) Same as calling add('section', $name, $value) =cut sub add_section { my $self = shift; return $self->add('section', @_); } =pod =head2 add_directive $directive = $obj->add_directive($name, $value) Same as calling add('directive', $name, $value) =cut sub add_directive { my $self = shift; return $self->add('directive', @_); } =pod =head2 add_comment $comment = $obj->add_comment("string", [$group]) Same as calling add('comment', 'string', ) $group is a boolean value that control grouping of consecutive comment lines. Disabled by default. =cut sub add_comment { my $self = shift; return $self->add('comment', @_); } =pod =head2 add_blank $blank = $obj->add_blank([$group]) Same as calling add('blank') $group is a boolean value that control grouping of consecutive blank lines. Enabled by default. =cut sub add_blank { my $self = shift; return $self->add('blank', @_); } =pod =head2 set_value $obj->set_value($newvalue) Change the value of a directive or section. If no argument given, return the value. =head2 value Returns the value of item pointed by the object if any. (Actually C and C are the same method) =cut *set_value = \&value; sub value { my $self = shift; my $newvalue = shift || return $self->{value}; my $type = $self->{type}; if($type eq 'directive' or $type eq 'section') { # keep indentation (my $indent = $self->{raw}) =~ s/^(\s*).*$/$1/s; if($newvalue =~ /\n/) { # new value is multilines # write the raw version $self->{raw} = sprintf ( $indent . ($type eq 'directive' ? '%s %s' : '<%s %s>')."\n", $self->{name}, join(" \\\n", split(/\n/, $newvalue)), ); # clean it $self->{value} = join(' ', map {s/^\s*|\s*$//g; $_} split(/\n/, $newvalue)); # count lines $self->{length} = 1 + $newvalue =~ s/\n//g; } else { if($type eq 'directive') { $self->{raw} = "$indent$self->{name} $newvalue\n"; } else { $self->{raw} = "$indent<$self->{name} $newvalue>\n"; } $self->{value} = $newvalue; $self->{length} = 1; } } elsif($type eq 'comment') { $newvalue = join(' ', split(/\n/, $newvalue)); # keep spaces before and after the sharp comment and the # number of sharps used (it's pure cosmetic) and put it on # front of the new comment $self->{raw} =~ s/^(\s*\#+\s*).*$/$1$newvalue\n/s; $self->{value} = $newvalue } else { return($self->_set_error('method not allowed')); } return($newvalue); } =pod =head2 move $obj->move ( $dest_section, -before => target | -after => $target | '-ontop' | '-onbottom' ) Move item into given section. See C method for options description. =cut sub move { my $self = shift; my $dest = shift; return $self->_set_error("cannot move this section in a subsection of itself") if($dest->isin($self, '-recursif')); $self->unlink(); $dest->add($self, @_); return; } =pod =head2 copy $item->copy ( $dest_section, -before => target | -after => $target | '-ontop' | '-onbottom' ) Copy item into given section. See C method for options description. =cut sub copy { my $self = shift; my $dest = shift; # clone item my $clone = $self->clone(); # insert into destination return $dest->add($clone, @_); } =pod =head2 clone $clone = $item->clone(); Clone item and all its children. Returns the cloned item. =cut sub clone { my($self) = @_; my $clone = bless({}); foreach(keys %$self) { next if $_ eq 'parent'; $clone->{$_} = $self->{$_}; } if($self->type() eq 'section') { # initialize children list $clone->{children} = []; # clone each children foreach($self->select()) { $clone->_add_child($_->clone()); } } return $clone; } =pod =head2 first_line =cut sub first_line { my($self) = @_; return 1 unless $self->parent; return ($self->top->_count_lines($self))[0]; } =pod =head2 last_line =cut sub last_line { my($self) = @_; return ($self->top->_count_lines($self))[0] unless $self->parent; return ($self->top->_count_lines_last($self))[0]; } =pod =head2 count_lines =cut sub count_lines { my($self) = @_; if($self->type eq 'section') { return $self->last_line - $self->first_line + 1; } else { return $self->{length}; } } =pod =head2 isin $boolean = $obj->($section_obj, ['-recursif']) Returns true if object point to a rule that is in the section represented by $section_obj. If C<-recursif> option is present, true is also return if object is a sub-section of target.
directive test
$test_directive->isin($target_section) => return false $test_directive->isin($sub_section) => return true $test_directive->isin($target_section, '-recursif') => return true $target_section->isin($target_section) => return true =cut sub isin { my $self = shift; my $recursif = _get_arg(\@_, '-recursif!'); my $target = shift || return $self->_set_error('too few arguments'); $target = $target->{tree} if ref $target eq 'Apache::Admin::Config'; return 0 unless(defined $self->{parent}); return($self->_set_error('target is not an object of myself')) unless(ref $target && $target->isa('Apache::Admin::Config::Tree')); return($self->_set_error('wrong type for target')) unless($target->{type} eq 'section'); return 1 if overload::StrVal($self) eq overload::StrVal($target); if($recursif) { my $parent = $self->{parent}; while(overload::StrVal($parent) ne overload::StrVal($target)) { $parent = $parent->{parent} || return 0; } return 1; } else { return(overload::StrVal($self->{parent}) eq overload::StrVal($target)) } } sub to_string { my($self, $other, $inv, $meth) = @_; if($meth eq 'eq') { if($^W and (!defined $other or !defined $self->{value})) { carp "Use of uninitialized value in string eq"; } local $^W; return($other ne $self->{value}); } elsif($meth eq 'ne') { if($^W and (!defined $other or !defined $self->{value})) { carp "Use of uninitialized value in string ne"; } local $^W; return($other ne $self->{value}); } elsif($meth eq '==') { if($^W and (!defined $other or !defined $self->{value})) { carp "Use of uninitialized value in numeric eq (==)"; } local $^W; return($other != $self->{value}); } elsif($meth eq '!=') { if($^W and (!defined $other or !defined $self->{value})) { carp "Use of uninitialized value in numeric ne (!=)"; } local $^W; return($other != $self->{value}); } elsif(!defined $self->{value}) { return overload::StrVal($self); } else { return $self->{value}; } } =pod =head2 name Returns the name of the current pointed object if any =head2 parent Returns the parent context of object. This method on the top level object returns C. =head2 type Returns the type of object. =cut sub name { return $_[0]->{name}; } sub parent { return $_[0]->{parent}; } sub top { my $top = shift; while(defined $top->parent()) { $top = $top->parent(); } return $top; } sub type { return $_[0]->{type}; } =pod =head2 remove Synonym for unlink (deprecated). See B. =head2 unlink $boolean = $item->unlink(); Unlinks item from the tree, resulting in two separate trees. The item to unlink becomes the root of a new tree. =cut *remove = \&unlink; sub unlink { my($self) = @_; if(defined $self->{parent}) { my $index = $self->_get_index; if(defined $index) { splice(@{$self->{parent}->{children}}, $index, 1); } } return 1; } =pod =head2 destroy $boolean = $item->destroy(); Destroy item and its children. Caution, you should call delete() method instead if you want destroy a part of a tree. This method don't notice item's parents of its death. =cut sub destroy { my($self) = @_; delete $self->{parent}; foreach(@{$self->{children}}) { $_->destroy; } return 1; } =pod =head2 delete $booleen = $item->delete; Remove the current item from it's parent children list and destroy it and all its children (remove() + destroy()). =cut sub delete { my($self) = @_; return $self->unlink() && $self->destroy(); } =pod =head2 error Return the last appended error. =cut sub error { return $_[0]->top()->{__last_error__}; } # # Private methods # sub _get_var { my($self, $name) = @_; my $value = $self->{$name}; until(defined $value) { $self = $self->parent() or last; } return $value; } sub _get_index { my($self) = @_; return unless defined $self->{parent}; # if called by top node my @pchildren = @{$self->{parent}->{children}}; for(my $i = 0; $i < @pchildren; $i++) { return $i if overload::StrVal($pchildren[$i]) eq overload::StrVal($self); } } sub _deploy { join '', map { if($_->{type} eq 'section') { ($_->{raw}, _deploy($_), $_->{raw2}); } else { $_->{raw}; } } @{$_[0]->{children}}; } sub _count_lines { my $c = $_[0]->{'length'} || 0; foreach my $i (@{$_[0]->{children}}) { return($c+1, 1) if(overload::StrVal($_[1]) eq overload::StrVal($i)); my($rv, $found) = $i->_count_lines($_[1]); $c += $rv; return($c, 1) if defined $found; } return $c + (defined $_[0]->{length2} ? $_[0]->{length2} : 0); } sub _count_lines_last { my $c = $_[0]->{'length'}; foreach my $i (@{$_[0]->{children}}) { $c += ($i->_count_lines($_[1]))[0]; return $c if($_[1] eq $i); } return $c + $_[0]->{length2}; } sub _add_child { my($self, $item, $index) = @_; $item->{parent} = $self; if(defined $index && $index != -1) { splice(@{$self->{children}}, $index, 0, $item); } else { push(@{$self->{children}}, $item); } } sub _insert_directive { my($tree, $directive_name, $value, $line, $length, $index) = @_; $value = defined $value ? $value : ''; $value =~ s/^\s+|\s+$//g; my $directive = bless({}); $directive->{type} = 'directive'; $directive->{name} = $directive_name; $directive->{value} = $value; $directive->{raw} = $line; $directive->{'length'} = $length; $tree->_add_child($directive, $index); return $directive; } sub _insert_section { my($tree, $section_name, $value, $line, $length, $index) = @_; $value = defined $value ? $value : ''; $value =~ s/^\s+|\s+$//g; my $section = bless({}); $section->{type} = 'section'; $section->{name} = $section_name; $section->{value} = $value; $section->{children} = []; $section->{raw} = $line; $section->{'length'} = $length; $tree->_add_child($section, $index); return $section; } sub _insert_comment { my($tree, $value, $line, $index, $group) = @_; my $comment = bless({}); # if last item is a comment, group next comment with it to make # multi-line comment instead of several single-line comment items my $_index = defined $index ? $index : -1; if(defined $group && $group && defined $tree->{children}->[$_index] && $tree->{children}->[$_index]->type eq 'comment') { $comment = $tree->{children}->[$_index]; $value = "\n$value"; } else { $comment->{type} = 'comment'; $tree->_add_child($comment, $index); } $comment->{value} .= $value; $comment->{raw} .= $line; $comment->{'length'}++; return $comment; } sub _insert_blank { my($tree, $line, $index, $group) = @_; my $blank = bless({}); # if last item is a blank line, group next blank line with it to # make multi-line blank item instead of several single-line blank # items my $_index = defined $index ? $index : -1; if(defined $group && $group && defined $tree->{children}->[$_index] && $tree->{children}->[$_index]->type eq 'blank') { $blank = $tree->{children}->[$_index]; } else { $blank->{type} = 'blank'; $tree->_add_child($blank, $index); } $blank->{raw} .= $line; $blank->{'length'}++; return $blank; } sub _parse { my($self, $fh) = @_; my $file = $self->{htaccess} || '[inline]'; my $cgroup = $self->{'comment-grouping'}; my $bgroup = $self->{'blank-grouping'}; # level is used to stock reference to the curent level, level[0] is the root level my @level = ($self); my($line, $raw_line); my $n = 0; while((defined $fh) && ($line = scalar <$fh>) && (defined $line)) { $n++; my $length = 1; $raw_line = $line; while($line !~ /^\s*#/ && $line =~ s/\\$//) { # line is truncated, we want the entire line $n++; $length++; chomp($line); my $next .= <$fh> or return $self->_set_error(sprintf('%s: syntax error at line %d', $file, $n)); $raw_line .= $next; $next =~ s/^\s*|\s*$//g; $line .= $next; } $line =~ s/^\s*|\s*$//g; if($line =~ /^\s*#\s?(.*?)\s*$/) { # it's a comment _insert_comment($level[-1], $1, $raw_line, undef, $cgroup); } elsif($line eq '') { # it's a blank line _insert_blank($level[-1], $raw_line, undef, $bgroup); } elsif($line =~ /^(\w+)(?:\s+(.*?)|)$/) { # it's a directive _insert_directive($level[-1], $1, $2, $raw_line, $length); } elsif($line =~ /^<\s*(\w+)(?:\s+([^>]+)|\s*)>$/) { # it's a section opening my $section = _insert_section($level[-1], $1, $2, $raw_line, $length); push(@level, $section); } elsif($line =~ /^<\/\s*(\w+)\s*>$/) { # it's a section closing my $section_name = lc $1; return $self->_set_error(sprintf('%s: syntax error at line %d', $file, $n)) if(!@level || $section_name ne lc($level[-1]->{name})); $level[-1]->{raw2} = $raw_line; $level[-1]->{length2} = $length; pop(@level); } else { return $self->_set_error(sprintf('%s: syntax error at line %d', $file, $n)); } } eval('use Data::Dumper; print Data::Dumper::Dumper($self), "\n";') if($Apache::Admin::Config::DEBUG); return 1; } sub _get_arg { my($args, $motif) = @_; # motif is a list of searched argument separated by a pipe # each arguments can be ended by a ! for specifing that it don't wait for a value # (ex: "-arg1|-arg2!" here -arg2 is boolean) # return (value, argname) return '' unless(@$args); for(my $n = 0; $n < @$args; $n++) { foreach my $name (split(/\|/, $motif)) { my $boolean = ($name =~ s/\!$//); if(defined $args->[$n] && !ref($args->[$n]) && $args->[$n] eq $name) { return(undef) if(!$boolean && $n+1 >= @$args); # malformed argument my $value = splice(@$args, $n, ($boolean?1:2)); $value = '' unless defined $value; return(wantarray ? ($value, $name) : $value); # suppres argument name and its value from the arglist and return the value } } } return ''; } sub _init { my $self = shift; return $self->_parse; } sub _load { my($self, $htaccess) = @_; my @htaccess; my $fh; $self->{htaccess} = $htaccess; if(ref $htaccess eq 'GLOB') { $fh = $htaccess; } else { # just return true if file doesn't exist and -create was enabled return 1 if(not -f $htaccess and $self->{create}); return $self->_set_error("`$htaccess' not readable") unless(-r $htaccess); $fh = new FileHandle($htaccess) or return $self->_set_error("can't open `$htaccess' file for reading"); } return $self->_parse($fh); } sub _set_error { my $self = shift; $Apache::Admin::Config::ERROR = $self->top->{__last_error__} = join('', (caller())[0].': ', @_); return; } 1; =pod =head1 EXAMPLES # # Reindent configuration file properly # my $conf = Apache::Admin::Config ( '/etc/apache/httpd.conf', -indent => 2 ); $conf->save('-reformat'); # # Managing virtual-hosts: # my $conf = new Apache::Admin::Config "/etc/apache/httpd.conf"; # adding a new virtual-host: my $vhost = $conf->add_section(VirtualHost=>'127.0.0.1'); $vhost->add_directive(ServerAdmin=>'webmaster@localhost.localdomain'); $vhost->add_directive(DocumentRoot=>'/usr/share/www'); $vhost->add_directive(ServerName=>'www.localhost.localdomain'); $vhost->add_directive(ErrorLog=>'/var/log/apache/www-error.log'); my $location = $vhost->add_section(Location=>'/admin'); $location->add_directive(AuthType=>'basic'); $location->add_directive(Require=>'group admin'); $conf->save; # selecting a virtual-host: my $vhost; foreach my $vh (@{$conf->section('VirtualHost')}) { if($vh->directive('ServerName')->value eq 'www.localhost.localdomain') { $vhost = $vh; last; } } # # Suppress all comments in the file # sub delete_comments { foreach(shift->comment) { $_->delete; } } sub delete_all_comments { foreach($_[0]->section) { delete_all_comments($_); } delete_comments($_[0]); } delete_all_comments($conf); # # Transform configuration file into XML format # my $c = new Apache::Admin::Config "/path/to/file", -indent => 2 or die $Apache::Admin::Config::ERROR; $c->set_write_directive(sub { my($self, $name, $value) = @_; return($self->indent.qq(\n)); }); $c->set_write_section_closing(sub { my($self, $name) = @_; return($self->indent."\n"); }); $c->set_write_comment(sub { my($self, $value) = @_; $value =~ s/\n//g; return($self->indent.""); }); print $c->dump_reformat(); =head1 AUTHOR Olivier Poitrey Ers@rhapsodyk.netE =head1 AVAILABILITY The official FTP location is: B Also available on CPAN. anonymous CVS repository: CVS_RSH=ssh cvs -d anonymous@cvs.rhapsodyk.net:/devel co Apache-Admin-Config (supply an empty string as password) CVS repository on the web: http://www.rhapsodyk.net/cgi-bin/cvsweb/Apache-Admin-Config/ =head1 BUGS Please send bug-reports to aac@list.rhapsodyk.net. You can subscribe to the list by sending an empty mail to aac-subscribe@list.rhapsodyk.net. =head1 LICENCE 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =head1 COPYRIGHT Copyright (C) 2001 - Olivier Poitrey Apache-Admin-Config-0.94/META.yml0000644000175000000620000000054710440613077016105 0ustar rsstaff00000000000000# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Apache-Admin-Config version: 0.94 version_from: lib/Apache/Admin/Config.pm installdirs: site requires: FileHandle: 2 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.17 Apache-Admin-Config-0.94/UPGRADE-0.100000644000175000000620000000140307361253705016220 0ustar rsstaff00000000000000Upgrade from 0.08 or earlier instructions: Some changes in API have been made since 0.08. If you have an older version than 0.10, you _have_ to upgrade you code before installing this version. Major changes are in ""directive()"" and ""section()"" methods. They no longer return an array ref where called in scalar context, but the latest item of the list. You are encouraged to modify your code, but, I know this can take a lot of time so you can activate the compatibility mode by call the contructor method ""new()"" with the argument ""-oldapi"" like this : my $obj = new Apache::Admin::Config ('/path/to/file', -oldapi=>1); Others changes in the new API shouldn't disturb your programs, so if you find any problem, please contact me at . Apache-Admin-Config-0.94/README0000644000175000000620000000435410440611766015517 0ustar rsstaff00000000000000Apache::Admin::Config 0.94 ========================== INSTALLATION To install this module type the following: perl Makefile.PL make make test make install NAME Apache::Admin::Config - A module to read/write Apache like configuration files DESCRIPTION "Apache::Admin::Config" provides an object oriented interface for reading and writing Apache-like configuration files without affecting comments, indentation, or truncated lines. You can easily extract informations from the apache configuration, or manage htaccess files. I wrote this class because I work for an IPP, and we often manipulate apache configuration files for adding new clients, activate some features or un/locking directories using htaccess, etc. It can also be useful for writing some one-shoot migrations scripts in few lines. AUTHOR Olivier Poitrey AVAILABILITY The official FTP location is: ftp://ftp.rhapsodyk.net/pub/devel/perl/Apache-Admin-Config-current.tar.g z Also available on CPAN. anonymous CVS repository: CVS_RSH=ssh cvs -d anonymous@cvs.rhapsodyk.net:/devel co Apache-Admin-Config (supply an empty string as password) CVS repository on the web: http://www.rhapsodyk.net/cgi-bin/cvsweb/Apache-Admin-Config/ BUGS Please send bug-reports to aac@list.rhapsodyk.net. You can subscribe to the list by sending an empty mail to aac-subscribe@list.rhapsodyk.net. LICENCE 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA COPYRIGHT Copyright (C) 2001 - Olivier Poitrey Apache-Admin-Config-0.94/Makefile.PL0000644000175000000620000000236007372215374016611 0ustar rsstaff00000000000000 use strict; use ExtUtils::MakeMaker; my $min_perl_version = 5.005; if($] < $min_perl_version) { print STDERR "This module will not work with perl version $]. It requires perl version $min_perl_version or higher\n"; exit 1; } eval('use Apache::Admin::Config'); if(!$@ && $Apache::Admin::Config::VERSION < 0.10) { $|++; print ( STDERR qq(Your actual version of Apache::Admin::Config ($Apache::Admin::Config::VERSION) use the old API.\n), qq(Changes in new API may dont work correctly with your programs, so you _have_ to read\n), qq(the documentation and the "UPDATE-0.10" file before installing this version.\n\n), qq(Would you like to install it anyway ? (Y/n):) ); my $answer = ; if($answer =~ /n/i) { print STDERR "Installation aborted.\n"; exit 1; } } WriteMakefile ( NAME => 'Apache::Admin::Config', DISTNAME => 'Apache-Admin-Config', VERSION_FROM => 'lib/Apache/Admin/Config.pm', # finds $VERSION PREREQ_PM => {FileHandle => 2.00}, PMLIBDIRS => ['lib'], ABSTRACT_FROM => 'lib/Apache/Admin/Config.pm', # retrieve abstract from module AUTHOR => 'Olivier Poitrey ', );