~ubuntu-branches/ubuntu/vivid/samba/vivid

« back to all changes in this revision

Viewing changes to source3/printing/printfsp.c

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
2
 
   Unix SMB/CIFS implementation.
3
 
   printing backend routines for smbd - using files_struct rather
4
 
   than only snum
5
 
   Copyright (C) Andrew Tridgell 1992-2000
6
 
   
7
 
   This program is free software; you can redistribute it and/or modify
8
 
   it under the terms of the GNU General Public License as published by
9
 
   the Free Software Foundation; either version 3 of the License, or
10
 
   (at your option) any later version.
11
 
   
12
 
   This program is distributed in the hope that it will be useful,
13
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
   GNU General Public License for more details.
16
 
   
17
 
   You should have received a copy of the GNU General Public License
18
 
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 
*/
20
 
 
21
 
#include "includes.h"
22
 
 
23
 
/***************************************************************************
24
 
open a print file and setup a fsp for it. This is a wrapper around
25
 
print_job_start().
26
 
***************************************************************************/
27
 
 
28
 
NTSTATUS print_fsp_open(struct smb_request *req, connection_struct *conn,
29
 
                        const char *fname,
30
 
                        uint16_t current_vuid, files_struct *fsp)
31
 
{
32
 
        int jobid;
33
 
        fstring name;
34
 
        NTSTATUS status;
35
 
 
36
 
        fstrcpy( name, "Remote Downlevel Document");
37
 
        if (fname) {
38
 
                const char *p = strrchr(fname, '/');
39
 
                fstrcat(name, " ");
40
 
                if (!p) {
41
 
                        p = fname;
42
 
                }
43
 
                fstrcat(name, p);
44
 
        }
45
 
 
46
 
        jobid = print_job_start(conn->server_info, SNUM(conn), name, NULL);
47
 
        if (jobid == -1) {
48
 
                status = map_nt_error_from_unix(errno);
49
 
                return status;
50
 
        }
51
 
 
52
 
        /* Convert to RAP id. */
53
 
        fsp->rap_print_jobid = pjobid_to_rap(lp_const_servicename(SNUM(conn)), jobid);
54
 
        if (fsp->rap_print_jobid == 0) {
55
 
                /* We need to delete the entry in the tdb. */
56
 
                pjob_delete(lp_const_servicename(SNUM(conn)), jobid);
57
 
                return NT_STATUS_ACCESS_DENIED; /* No errno around here */
58
 
        }
59
 
 
60
 
        status = create_synthetic_smb_fname(fsp,
61
 
            print_job_fname(lp_const_servicename(SNUM(conn)), jobid), NULL,
62
 
            NULL, &fsp->fsp_name);
63
 
        if (!NT_STATUS_IS_OK(status)) {
64
 
                pjob_delete(lp_const_servicename(SNUM(conn)), jobid);
65
 
                return status;
66
 
        }
67
 
        /* setup a full fsp */
68
 
        fsp->fh->fd = print_job_fd(lp_const_servicename(SNUM(conn)),jobid);
69
 
        GetTimeOfDay(&fsp->open_time);
70
 
        fsp->vuid = current_vuid;
71
 
        fsp->fh->pos = -1;
72
 
        fsp->can_lock = True;
73
 
        fsp->can_read = False;
74
 
        fsp->access_mask = FILE_GENERIC_WRITE;
75
 
        fsp->can_write = True;
76
 
        fsp->print_file = True;
77
 
        fsp->modified = False;
78
 
        fsp->oplock_type = NO_OPLOCK;
79
 
        fsp->sent_oplock_break = NO_BREAK_SENT;
80
 
        fsp->is_directory = False;
81
 
        fsp->wcp = NULL;
82
 
        SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st);
83
 
        fsp->mode = fsp->fsp_name->st.st_ex_mode;
84
 
        fsp->file_id = vfs_file_id_from_sbuf(conn, &fsp->fsp_name->st);
85
 
 
86
 
        return NT_STATUS_OK;
87
 
}
88
 
 
89
 
/****************************************************************************
90
 
 Print a file - called on closing the file.
91
 
****************************************************************************/
92
 
 
93
 
void print_fsp_end(files_struct *fsp, enum file_close_type close_type)
94
 
{
95
 
        uint32 jobid;
96
 
 
97
 
        if (fsp->fh->private_options & FILE_DELETE_ON_CLOSE) {
98
 
                /*
99
 
                 * Truncate the job. print_job_end will take
100
 
                 * care of deleting it for us. JRA.
101
 
                 */
102
 
                sys_ftruncate(fsp->fh->fd, 0);
103
 
        }
104
 
 
105
 
        if (fsp->fsp_name) {
106
 
                TALLOC_FREE(fsp->fsp_name);
107
 
        }
108
 
 
109
 
        if (!rap_to_pjobid(fsp->rap_print_jobid, NULL, &jobid)) {
110
 
                DEBUG(3,("print_fsp_end: Unable to convert RAP jobid %u to print jobid.\n",
111
 
                        (unsigned int)fsp->rap_print_jobid ));
112
 
                return;
113
 
        }
114
 
 
115
 
        print_job_end(SNUM(fsp->conn),jobid, close_type);
116
 
}