Ignore:
Timestamp:
Nov 27, 2012, 4:56:06 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated vendor to 3.6.9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/lib/util.c

    r740 r746  
    2929#include "../lib/util/util_pw.h"
    3030#include "messages.h"
     31#include "libcli/security/security.h"
    3132
    3233extern char *global_clobber_region_function;
     
    27232724        return ptr;
    27242725}
     2726
     2727/*******************************************************************
     2728 Return True if the filename is one of the special executable types.
     2729********************************************************************/
     2730
     2731bool is_executable(const char *fname)
     2732{
     2733        if ((fname = strrchr_m(fname,'.'))) {
     2734                if (strequal(fname,".com") ||
     2735                    strequal(fname,".dll") ||
     2736                    strequal(fname,".exe") ||
     2737                    strequal(fname,".sym")) {
     2738                        return True;
     2739                }
     2740        }
     2741        return False;
     2742}
     2743
     2744/****************************************************************************
     2745 Open a file with a share mode - old openX method - map into NTCreate.
     2746****************************************************************************/
     2747
     2748bool map_open_params_to_ntcreate(const char *smb_base_fname,
     2749                                 int deny_mode, int open_func,
     2750                                 uint32 *paccess_mask,
     2751                                 uint32 *pshare_mode,
     2752                                 uint32 *pcreate_disposition,
     2753                                 uint32 *pcreate_options,
     2754                                 uint32_t *pprivate_flags)
     2755{
     2756        uint32 access_mask;
     2757        uint32 share_mode;
     2758        uint32 create_disposition;
     2759        uint32 create_options = FILE_NON_DIRECTORY_FILE;
     2760        uint32_t private_flags = 0;
     2761
     2762        DEBUG(10,("map_open_params_to_ntcreate: fname = %s, deny_mode = 0x%x, "
     2763                  "open_func = 0x%x\n",
     2764                  smb_base_fname, (unsigned int)deny_mode,
     2765                  (unsigned int)open_func ));
     2766
     2767        /* Create the NT compatible access_mask. */
     2768        switch (GET_OPENX_MODE(deny_mode)) {
     2769                case DOS_OPEN_EXEC: /* Implies read-only - used to be FILE_READ_DATA */
     2770                case DOS_OPEN_RDONLY:
     2771                        access_mask = FILE_GENERIC_READ;
     2772                        break;
     2773                case DOS_OPEN_WRONLY:
     2774                        access_mask = FILE_GENERIC_WRITE;
     2775                        break;
     2776                case DOS_OPEN_RDWR:
     2777                case DOS_OPEN_FCB:
     2778                        access_mask = FILE_GENERIC_READ|FILE_GENERIC_WRITE;
     2779                        break;
     2780                default:
     2781                        DEBUG(10,("map_open_params_to_ntcreate: bad open mode = 0x%x\n",
     2782                                  (unsigned int)GET_OPENX_MODE(deny_mode)));
     2783                        return False;
     2784        }
     2785
     2786        /* Create the NT compatible create_disposition. */
     2787        switch (open_func) {
     2788                case OPENX_FILE_EXISTS_FAIL|OPENX_FILE_CREATE_IF_NOT_EXIST:
     2789                        create_disposition = FILE_CREATE;
     2790                        break;
     2791
     2792                case OPENX_FILE_EXISTS_OPEN:
     2793                        create_disposition = FILE_OPEN;
     2794                        break;
     2795
     2796                case OPENX_FILE_EXISTS_OPEN|OPENX_FILE_CREATE_IF_NOT_EXIST:
     2797                        create_disposition = FILE_OPEN_IF;
     2798                        break;
     2799
     2800                case OPENX_FILE_EXISTS_TRUNCATE:
     2801                        create_disposition = FILE_OVERWRITE;
     2802                        break;
     2803
     2804                case OPENX_FILE_EXISTS_TRUNCATE|OPENX_FILE_CREATE_IF_NOT_EXIST:
     2805                        create_disposition = FILE_OVERWRITE_IF;
     2806                        break;
     2807
     2808                default:
     2809                        /* From samba4 - to be confirmed. */
     2810                        if (GET_OPENX_MODE(deny_mode) == DOS_OPEN_EXEC) {
     2811                                create_disposition = FILE_CREATE;
     2812                                break;
     2813                        }
     2814                        DEBUG(10,("map_open_params_to_ntcreate: bad "
     2815                                  "open_func 0x%x\n", (unsigned int)open_func));
     2816                        return False;
     2817        }
     2818
     2819        /* Create the NT compatible share modes. */
     2820        switch (GET_DENY_MODE(deny_mode)) {
     2821                case DENY_ALL:
     2822                        share_mode = FILE_SHARE_NONE;
     2823                        break;
     2824
     2825                case DENY_WRITE:
     2826                        share_mode = FILE_SHARE_READ;
     2827                        break;
     2828
     2829                case DENY_READ:
     2830                        share_mode = FILE_SHARE_WRITE;
     2831                        break;
     2832
     2833                case DENY_NONE:
     2834                        share_mode = FILE_SHARE_READ|FILE_SHARE_WRITE;
     2835                        break;
     2836
     2837                case DENY_DOS:
     2838                        private_flags |= NTCREATEX_OPTIONS_PRIVATE_DENY_DOS;
     2839                        if (is_executable(smb_base_fname)) {
     2840                                share_mode = FILE_SHARE_READ|FILE_SHARE_WRITE;
     2841                        } else {
     2842                                if (GET_OPENX_MODE(deny_mode) == DOS_OPEN_RDONLY) {
     2843                                        share_mode = FILE_SHARE_READ;
     2844                                } else {
     2845                                        share_mode = FILE_SHARE_NONE;
     2846                                }
     2847                        }
     2848                        break;
     2849
     2850                case DENY_FCB:
     2851                        private_flags |= NTCREATEX_OPTIONS_PRIVATE_DENY_FCB;
     2852                        share_mode = FILE_SHARE_NONE;
     2853                        break;
     2854
     2855                default:
     2856                        DEBUG(10,("map_open_params_to_ntcreate: bad deny_mode 0x%x\n",
     2857                                (unsigned int)GET_DENY_MODE(deny_mode) ));
     2858                        return False;
     2859        }
     2860
     2861        DEBUG(10,("map_open_params_to_ntcreate: file %s, access_mask = 0x%x, "
     2862                  "share_mode = 0x%x, create_disposition = 0x%x, "
     2863                  "create_options = 0x%x private_flags = 0x%x\n",
     2864                  smb_base_fname,
     2865                  (unsigned int)access_mask,
     2866                  (unsigned int)share_mode,
     2867                  (unsigned int)create_disposition,
     2868                  (unsigned int)create_options,
     2869                  (unsigned int)private_flags));
     2870
     2871        if (paccess_mask) {
     2872                *paccess_mask = access_mask;
     2873        }
     2874        if (pshare_mode) {
     2875                *pshare_mode = share_mode;
     2876        }
     2877        if (pcreate_disposition) {
     2878                *pcreate_disposition = create_disposition;
     2879        }
     2880        if (pcreate_options) {
     2881                *pcreate_options = create_options;
     2882        }
     2883        if (pprivate_flags) {
     2884                *pprivate_flags = private_flags;
     2885        }
     2886
     2887        return True;
     2888
     2889}
Note: See TracChangeset for help on using the changeset viewer.