Bugzilla – Attachment 173 Details for
Bug 430
Could add option to sftp-server to disable write access
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
adds readonly flag to sftp-server
45 (text/plain), 3.56 KB, created by
gfernandez
on 2002-11-08 00:32:25 AEDT
(
hide
)
Description:
adds readonly flag to sftp-server
Filename:
MIME Type:
Creator:
gfernandez
Created:
2002-11-08 00:32:25 AEDT
Size:
3.56 KB
patch
obsolete
>diff -u ../openssh-3.4p1/sftp-server.c . >--- ../openssh-3.4p1/sftp-server.c Tue Jun 25 19:21:41 2002 >+++ ./sftp-server.c Tue Nov 5 10:42:49 2002 >@@ -52,6 +52,9 @@ > /* Version of client */ > int version; > >+/* deny client write operations */ >+int readonly = 0; >+ > /* portable attibutes, etc. */ > > typedef struct Stat Stat; >@@ -390,6 +393,12 @@ > pflags = get_int(); /* portable flags */ > a = get_attrib(); > flags = flags_from_portable(pflags); >+ if (((flags & O_ACCMODE) == O_RDWR) || >+ ((flags & O_ACCMODE) == O_WRONLY)) { >+ status = SSH2_FX_PERMISSION_DENIED; >+ send_status(id, status); >+ return; >+ } > mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? a->perm : 0666; > TRACE("open id %u name %s flags %d mode 0%o", id, name, pflags, mode); > fd = open(name, flags, mode); >@@ -587,6 +596,11 @@ > id = get_int(); > name = get_string(NULL); > a = get_attrib(); >+ if (readonly) { >+ status = SSH2_FX_PERMISSION_DENIED; >+ send_status(id, status); >+ return; >+ } > TRACE("setstat id %u name %s", id, name); > if (a->flags & SSH2_FILEXFER_ATTR_SIZE) { > ret = truncate(name, a->size); >@@ -604,7 +618,7 @@ > status = errno_to_portable(errno); > } > if (a->flags & SSH2_FILEXFER_ATTR_UIDGID) { >- ret = chown(name, a->uid, a->gid); >+ ret = lchown(name, a->uid, a->gid); > if (ret == -1) > status = errno_to_portable(errno); > } >@@ -802,6 +816,11 @@ > > id = get_int(); > name = get_string(NULL); >+ if (readonly) { >+ status = SSH2_FX_PERMISSION_DENIED; >+ send_status(id, status); >+ return; >+ } > TRACE("remove id %u name %s", id, name); > ret = unlink(name); > status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK; >@@ -820,6 +839,11 @@ > id = get_int(); > name = get_string(NULL); > a = get_attrib(); >+ if (readonly) { >+ status = SSH2_FX_PERMISSION_DENIED; >+ send_status(id, status); >+ return; >+ } > mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? > a->perm & 0777 : 0777; > TRACE("mkdir id %u name %s mode 0%o", id, name, mode); >@@ -838,6 +862,11 @@ > > id = get_int(); > name = get_string(NULL); >+ if (readonly) { >+ status = SSH2_FX_PERMISSION_DENIED; >+ send_status(id, status); >+ return; >+ } > TRACE("rmdir id %u name %s", id, name); > ret = rmdir(name); > status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK; >@@ -881,6 +910,11 @@ > id = get_int(); > oldpath = get_string(NULL); > newpath = get_string(NULL); >+ if (readonly) { >+ status = SSH2_FX_PERMISSION_DENIED; >+ send_status(id, status); >+ return; >+ } > TRACE("rename id %u old %s new %s", id, oldpath, newpath); > /* fail if 'newpath' exists */ > if (stat(newpath, &st) == -1) { >@@ -927,6 +970,11 @@ > id = get_int(); > oldpath = get_string(NULL); > newpath = get_string(NULL); >+ if (readonly) { >+ status = SSH2_FX_PERMISSION_DENIED; >+ send_status(id, status); >+ return; >+ } > TRACE("symlink id %u old %s new %s", id, oldpath, newpath); > /* fail if 'newpath' exists */ > if (stat(newpath, &st) == -1) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 430
:
173
|
586
|
1763