mod_authz_owner.c revision b6b9713c05233c99a1df07b882f985f1474f891d
0c04407550130c0ea040b5675f2c214426b27718fuankg/* Licensed to the Apache Software Foundation (ASF) under one or more
0c04407550130c0ea040b5675f2c214426b27718fuankg * contributor license agreements. See the NOTICE file distributed with
0c04407550130c0ea040b5675f2c214426b27718fuankg * this work for additional information regarding copyright ownership.
0c04407550130c0ea040b5675f2c214426b27718fuankg * The ASF licenses this file to You under the Apache License, Version 2.0
0c04407550130c0ea040b5675f2c214426b27718fuankg * (the "License"); you may not use this file except in compliance with
0c04407550130c0ea040b5675f2c214426b27718fuankg * the License. You may obtain a copy of the License at
0c04407550130c0ea040b5675f2c214426b27718fuankg * Unless required by applicable law or agreed to in writing, software
0662ed52e814f8f08ef0e09956413a792584eddffuankg * distributed under the License is distributed on an "AS IS" BASIS,
0c04407550130c0ea040b5675f2c214426b27718fuankg * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0c04407550130c0ea040b5675f2c214426b27718fuankg * See the License for the specific language governing permissions and
0c04407550130c0ea040b5675f2c214426b27718fuankg * limitations under the License.
0c04407550130c0ea040b5675f2c214426b27718fuankgAPR_DECLARE_OPTIONAL_FN(char*, authz_owner_get_file_group, (request_rec *r));
0c04407550130c0ea040b5675f2c214426b27718fuankgstatic authz_status fileowner_check_authorization(request_rec *r,
0c04407550130c0ea040b5675f2c214426b27718fuankg reason = "'Require file-owner' is not supported on this platform.";
0c04407550130c0ea040b5675f2c214426b27718fuankg "Authorization of user %s to access %s failed, reason: %s",
0c04407550130c0ea040b5675f2c214426b27718fuankg#else /* APR_HAS_USER */
0c04407550130c0ea040b5675f2c214426b27718fuankg "access to %s failed, reason: no authenticated user", r->uri);
0c04407550130c0ea040b5675f2c214426b27718fuankg "Authorization of user %s to access %s failed, reason: %s",
0c04407550130c0ea040b5675f2c214426b27718fuankg status = apr_stat(&finfo, r->filename, APR_FINFO_USER, r->pool);
0c04407550130c0ea040b5675f2c214426b27718fuankg reason = apr_pstrcat(r->pool, "could not stat file ",
0c04407550130c0ea040b5675f2c214426b27718fuankg "Authorization of user %s to access %s failed, reason: %s",
0c04407550130c0ea040b5675f2c214426b27718fuankg "Authorization of user %s to access %s failed, reason: %s",
0c04407550130c0ea040b5675f2c214426b27718fuankg status = apr_uid_name_get(&owner, finfo.user, r->pool);
0c04407550130c0ea040b5675f2c214426b27718fuankg "Authorization of user %s to access %s failed, reason: %s",
0c04407550130c0ea040b5675f2c214426b27718fuankg reason = apr_psprintf(r->pool, "file owner %s does not match.",
0c04407550130c0ea040b5675f2c214426b27718fuankg "Authorization of user %s to access %s failed, reason: %s",
0c04407550130c0ea040b5675f2c214426b27718fuankg /* this user is authorized */
0c04407550130c0ea040b5675f2c214426b27718fuankg#endif /* APR_HAS_USER */
0c04407550130c0ea040b5675f2c214426b27718fuankgstatic char *authz_owner_get_file_group(request_rec *r)
0c04407550130c0ea040b5675f2c214426b27718fuankg /* file-group only figures out the file's group and lets
0c04407550130c0ea040b5675f2c214426b27718fuankg * other modules do the actual authorization (against a group file/db).
0c04407550130c0ea040b5675f2c214426b27718fuankg * Thus, these modules have to hook themselves after
0c04407550130c0ea040b5675f2c214426b27718fuankg * mod_authz_owner and of course recognize 'file-group', too.
0c04407550130c0ea040b5675f2c214426b27718fuankg#else /* APR_HAS_USER */
0c04407550130c0ea040b5675f2c214426b27718fuankg "Authorization of user %s to access %s failed, reason: %s",
0c04407550130c0ea040b5675f2c214426b27718fuankg status = apr_stat(&finfo, r->filename, APR_FINFO_GROUP, r->pool);
0c04407550130c0ea040b5675f2c214426b27718fuankg reason = apr_pstrcat(r->pool, "could not stat file ",
0c04407550130c0ea040b5675f2c214426b27718fuankg "Authorization of user %s to access %s failed, reason: %s",
0c04407550130c0ea040b5675f2c214426b27718fuankg "Authorization of user %s to access %s failed, reason: %s",
0c04407550130c0ea040b5675f2c214426b27718fuankg status = apr_gid_name_get(&group, finfo.group, r->pool);
0c04407550130c0ea040b5675f2c214426b27718fuankg "Authorization of user %s to access %s failed, reason: %s",
0c04407550130c0ea040b5675f2c214426b27718fuankg#endif /* APR_HAS_USER */
0c04407550130c0ea040b5675f2c214426b27718fuankgstatic const authz_provider authz_fileowner_provider =
0c04407550130c0ea040b5675f2c214426b27718fuankg APR_REGISTER_OPTIONAL_FN(authz_owner_get_file_group);