s3-auth: smbd needs auth.h
[ira/wip.git] / source3 / smbd / fake_file.c
index 743d88f360c6d27d098c3611b01a4badf5cde7b4..81f7686726b171a33654d47754596f8c98abea06 100644 (file)
@@ -18,6 +18,9 @@
 */
 
 #include "includes.h"
+#include "smbd/smbd.h"
+#include "fake_file.h"
+#include "auth.h"
 
 struct fake_file_type {
        const char *name;
@@ -71,38 +74,46 @@ static struct fake_file_handle *init_fake_file_handle(enum FAKE_FILE_TYPE type)
  Does this name match a fake filename ?
 ****************************************************************************/
 
-enum FAKE_FILE_TYPE is_fake_file(const struct smb_filename *smb_fname)
+enum FAKE_FILE_TYPE is_fake_file_path(const char *path)
 {
-#ifdef HAVE_SYS_QUOTAS
        int i;
+
+       if (!path) {
+               return FAKE_FILE_TYPE_NONE;
+       }
+
+       for (i=0;fake_files[i].name!=NULL;i++) {
+               if (strncmp(path,fake_files[i].name,strlen(fake_files[i].name))==0) {
+                       DEBUG(5,("is_fake_file: [%s] is a fake file\n",path));
+                       return fake_files[i].type;
+               }
+       }
+
+       return FAKE_FILE_TYPE_NONE;
+}
+
+enum FAKE_FILE_TYPE is_fake_file(const struct smb_filename *smb_fname)
+{
        char *fname = NULL;
        NTSTATUS status;
-#endif
+       enum FAKE_FILE_TYPE ret;
 
        if (!smb_fname) {
                return FAKE_FILE_TYPE_NONE;
        }
 
-#ifdef HAVE_SYS_QUOTAS
        status = get_full_smb_filename(talloc_tos(), smb_fname, &fname);
        if (!NT_STATUS_IS_OK(status)) {
                return FAKE_FILE_TYPE_NONE;
        }
 
-       for (i=0;fake_files[i].name!=NULL;i++) {
-               if (strncmp(fname,fake_files[i].name,strlen(fake_files[i].name))==0) {
-                       DEBUG(5,("is_fake_file: [%s] is a fake file\n",fname));
-                       TALLOC_FREE(fname);
-                       return fake_files[i].type;
-               }
-       }
+       ret = is_fake_file_path(fname);
+
        TALLOC_FREE(fname);
-#endif
 
-       return FAKE_FILE_TYPE_NONE;
+       return ret;
 }
 
-
 /****************************************************************************
  Open a fake quota file with a share mode.
 ****************************************************************************/
@@ -118,12 +129,12 @@ NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn,
        NTSTATUS status;
 
        /* access check */
-       if (conn->server_info->utok.uid != 0) {
+       if (geteuid() != sec_initial_uid()) {
                DEBUG(3, ("open_fake_file_shared: access_denied to "
                          "service[%s] file[%s] user[%s]\n",
                          lp_servicename(SNUM(conn)),
                          smb_fname_str_dbg(smb_fname),
-                         conn->server_info->unix_name));
+                         conn->session_info->unix_name));
                return NT_STATUS_ACCESS_DENIED;
 
        }