mirror of
https://github.com/samba-team/samba.git
synced 2025-02-28 01:58:17 +03:00
Add the ability to parse out the port to SMBC_parse_path().
Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
This commit is contained in:
parent
c0cbf5936f
commit
534cf516ed
@ -415,6 +415,7 @@ SMBC_parse_path(TALLOC_CTX *ctx,
|
||||
const char *fname,
|
||||
char **pp_workgroup,
|
||||
char **pp_server,
|
||||
uint16_t *p_port,
|
||||
char **pp_share,
|
||||
char **pp_path,
|
||||
char **pp_user,
|
||||
|
@ -378,6 +378,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
|
||||
char *workgroup = NULL;
|
||||
char *path = NULL;
|
||||
uint16 mode;
|
||||
uint16_t port = 0;
|
||||
char *p = NULL;
|
||||
SMBCSRV *srv = NULL;
|
||||
SMBCFILE *dir = NULL;
|
||||
@ -404,6 +405,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
|
||||
fname,
|
||||
&workgroup,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
@ -1161,6 +1163,7 @@ SMBC_mkdir_ctx(SMBCCTX *context,
|
||||
char *workgroup = NULL;
|
||||
char *path = NULL;
|
||||
char *targetpath = NULL;
|
||||
uint16_t port = 0;
|
||||
struct cli_state *targetcli = NULL;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
NTSTATUS status;
|
||||
@ -1184,6 +1187,7 @@ SMBC_mkdir_ctx(SMBCCTX *context,
|
||||
fname,
|
||||
&workgroup,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
@ -1270,6 +1274,7 @@ SMBC_rmdir_ctx(SMBCCTX *context,
|
||||
char *workgroup = NULL;
|
||||
char *path = NULL;
|
||||
char *targetpath = NULL;
|
||||
uint16_t port = 0;
|
||||
struct cli_state *targetcli = NULL;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
NTSTATUS status;
|
||||
@ -1293,6 +1298,7 @@ SMBC_rmdir_ctx(SMBCCTX *context,
|
||||
fname,
|
||||
&workgroup,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
@ -1557,6 +1563,7 @@ SMBC_chmod_ctx(SMBCCTX *context,
|
||||
struct cli_state *targetcli = NULL;
|
||||
char *path = NULL;
|
||||
uint16 mode;
|
||||
uint16_t port = 0;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
NTSTATUS status;
|
||||
|
||||
@ -1580,6 +1587,7 @@ SMBC_chmod_ctx(SMBCCTX *context,
|
||||
fname,
|
||||
&workgroup,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
@ -1648,6 +1656,7 @@ SMBC_utimes_ctx(SMBCCTX *context,
|
||||
char *path = NULL;
|
||||
time_t access_time;
|
||||
time_t write_time;
|
||||
uint16_t port = 0;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
|
||||
if (!context || !context->internal->initialized) {
|
||||
@ -1696,6 +1705,7 @@ SMBC_utimes_ctx(SMBCCTX *context,
|
||||
fname,
|
||||
&workgroup,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
@ -1748,6 +1758,7 @@ SMBC_unlink_ctx(SMBCCTX *context,
|
||||
char *workgroup = NULL;
|
||||
char *path = NULL;
|
||||
char *targetpath = NULL;
|
||||
uint16_t port = 0;
|
||||
struct cli_state *targetcli = NULL;
|
||||
SMBCSRV *srv = NULL;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
@ -1773,6 +1784,7 @@ SMBC_unlink_ctx(SMBCCTX *context,
|
||||
fname,
|
||||
&workgroup,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
@ -1886,6 +1898,8 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
|
||||
struct cli_state *targetcli1 = NULL;
|
||||
struct cli_state *targetcli2 = NULL;
|
||||
SMBCSRV *srv = NULL;
|
||||
uint16_t port1 = 0;
|
||||
uint16_t port2 = 0;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
NTSTATUS status;
|
||||
|
||||
@ -1911,6 +1925,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
|
||||
oname,
|
||||
&workgroup,
|
||||
&server1,
|
||||
&port1,
|
||||
&share1,
|
||||
&path1,
|
||||
&user1,
|
||||
@ -1935,6 +1950,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
|
||||
nname,
|
||||
NULL,
|
||||
&server2,
|
||||
&port2,
|
||||
&share2,
|
||||
&path2,
|
||||
&user2,
|
||||
|
@ -49,6 +49,7 @@ SMBC_open_ctx(SMBCCTX *context,
|
||||
SMBCSRV *srv = NULL;
|
||||
SMBCFILE *file = NULL;
|
||||
uint16_t fd;
|
||||
uint16_t port = 0;
|
||||
NTSTATUS status = NT_STATUS_OBJECT_PATH_INVALID;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
|
||||
@ -69,6 +70,7 @@ SMBC_open_ctx(SMBCCTX *context,
|
||||
fname,
|
||||
&workgroup,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
@ -230,6 +232,7 @@ SMBC_read_ctx(SMBCCTX *context,
|
||||
char *path = NULL;
|
||||
char *targetpath = NULL;
|
||||
struct cli_state *targetcli = NULL;
|
||||
uint16_t port = 0;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
NTSTATUS status;
|
||||
|
||||
@ -274,6 +277,7 @@ SMBC_read_ctx(SMBCCTX *context,
|
||||
file->fname,
|
||||
NULL,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
@ -327,6 +331,7 @@ SMBC_write_ctx(SMBCCTX *context,
|
||||
char *path = NULL;
|
||||
char *targetpath = NULL;
|
||||
struct cli_state *targetcli = NULL;
|
||||
uint16_t port = 0;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
NTSTATUS status;
|
||||
|
||||
@ -360,6 +365,7 @@ SMBC_write_ctx(SMBCCTX *context,
|
||||
file->fname,
|
||||
NULL,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
@ -408,6 +414,7 @@ SMBC_close_ctx(SMBCCTX *context,
|
||||
char *server = NULL, *share = NULL, *user = NULL, *password = NULL;
|
||||
char *path = NULL;
|
||||
char *targetpath = NULL;
|
||||
uint16_t port = 0;
|
||||
struct cli_state *targetcli = NULL;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
NTSTATUS status;
|
||||
@ -436,6 +443,7 @@ SMBC_close_ctx(SMBCCTX *context,
|
||||
file->fname,
|
||||
NULL,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
@ -684,6 +692,7 @@ SMBC_lseek_ctx(SMBCCTX *context,
|
||||
char *path = NULL;
|
||||
char *targetpath = NULL;
|
||||
struct cli_state *targetcli = NULL;
|
||||
uint16_t port = 0;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
NTSTATUS status;
|
||||
|
||||
@ -719,6 +728,7 @@ SMBC_lseek_ctx(SMBCCTX *context,
|
||||
file->fname,
|
||||
NULL,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
@ -782,6 +792,7 @@ SMBC_ftruncate_ctx(SMBCCTX *context,
|
||||
char *password = NULL;
|
||||
char *path = NULL;
|
||||
char *targetpath = NULL;
|
||||
uint16_t port = 0;
|
||||
struct cli_state *targetcli = NULL;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
NTSTATUS status;
|
||||
@ -810,6 +821,7 @@ SMBC_ftruncate_ctx(SMBCCTX *context,
|
||||
file->fname,
|
||||
NULL,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
|
@ -224,6 +224,7 @@ SMBC_parse_path(TALLOC_CTX *ctx,
|
||||
const char *fname,
|
||||
char **pp_workgroup,
|
||||
char **pp_server,
|
||||
uint16_t *p_port,
|
||||
char **pp_share,
|
||||
char **pp_path,
|
||||
char **pp_user,
|
||||
@ -238,6 +239,7 @@ SMBC_parse_path(TALLOC_CTX *ctx,
|
||||
|
||||
/* Ensure these returns are at least valid pointers. */
|
||||
*pp_server = talloc_strdup(ctx, "");
|
||||
*p_port = 0;
|
||||
*pp_share = talloc_strdup(ctx, "");
|
||||
*pp_path = talloc_strdup(ctx, "");
|
||||
*pp_user = talloc_strdup(ctx, "");
|
||||
@ -363,6 +365,28 @@ SMBC_parse_path(TALLOC_CTX *ctx,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Does *pp_server contain a ':' ? If so
|
||||
* this denotes the port.
|
||||
*/
|
||||
q = strchr_m(*pp_server, ':');
|
||||
if (q != NULL) {
|
||||
long int port;
|
||||
char *endptr = NULL;
|
||||
*q = '\0';
|
||||
q++;
|
||||
if (*q == '\0') {
|
||||
/* Bad port. */
|
||||
return -1;
|
||||
}
|
||||
port = strtol(q, &endptr, 10);
|
||||
if (*endptr != '\0') {
|
||||
/* Bad port. */
|
||||
return -1;
|
||||
}
|
||||
*p_port = (uint16_t)port;
|
||||
}
|
||||
|
||||
if (*p == (char)0) {
|
||||
goto decoding; /* That's it ... */
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ SMBC_open_print_job_ctx(SMBCCTX *context,
|
||||
char *user = NULL;
|
||||
char *password = NULL;
|
||||
char *path = NULL;
|
||||
uint16_t port = 0;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
|
||||
if (!context || !context->internal->initialized) {
|
||||
@ -62,6 +63,7 @@ SMBC_open_print_job_ctx(SMBCCTX *context,
|
||||
fname,
|
||||
NULL,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
@ -190,6 +192,7 @@ SMBC_list_print_jobs_ctx(SMBCCTX *context,
|
||||
char *password = NULL;
|
||||
char *workgroup = NULL;
|
||||
char *path = NULL;
|
||||
uint16_t port = 0;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
|
||||
if (!context || !context->internal->initialized) {
|
||||
@ -211,6 +214,7 @@ SMBC_list_print_jobs_ctx(SMBCCTX *context,
|
||||
fname,
|
||||
&workgroup,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
@ -266,6 +270,7 @@ SMBC_unlink_print_job_ctx(SMBCCTX *context,
|
||||
char *workgroup = NULL;
|
||||
char *path = NULL;
|
||||
int err;
|
||||
uint16_t port = 0;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
|
||||
if (!context || !context->internal->initialized) {
|
||||
@ -287,6 +292,7 @@ SMBC_unlink_print_job_ctx(SMBCCTX *context,
|
||||
fname,
|
||||
&workgroup,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
|
@ -120,6 +120,7 @@ SMBC_stat_ctx(SMBCCTX *context,
|
||||
struct timespec change_time_ts;
|
||||
off_t size = 0;
|
||||
uint16 mode = 0;
|
||||
uint16_t port = 0;
|
||||
SMB_INO_T ino = 0;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
|
||||
@ -142,6 +143,7 @@ SMBC_stat_ctx(SMBCCTX *context,
|
||||
fname,
|
||||
&workgroup,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
@ -214,6 +216,7 @@ SMBC_fstat_ctx(SMBCCTX *context,
|
||||
char *targetpath = NULL;
|
||||
struct cli_state *targetcli = NULL;
|
||||
SMB_INO_T ino = 0;
|
||||
uint16_t port = 0;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
NTSTATUS status;
|
||||
|
||||
@ -240,6 +243,7 @@ SMBC_fstat_ctx(SMBCCTX *context,
|
||||
file->fname,
|
||||
NULL,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
|
@ -1724,6 +1724,7 @@ SMBC_setxattr_ctx(SMBCCTX *context,
|
||||
const char * write_time_attr;
|
||||
const char * change_time_attr;
|
||||
} attr_strings;
|
||||
uint16_t port = 0;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
|
||||
if (!context || !context->internal->initialized) {
|
||||
@ -1746,6 +1747,7 @@ SMBC_setxattr_ctx(SMBCCTX *context,
|
||||
fname,
|
||||
&workgroup,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
@ -2018,6 +2020,7 @@ SMBC_getxattr_ctx(SMBCCTX *context,
|
||||
const char * write_time_attr;
|
||||
const char * change_time_attr;
|
||||
} attr_strings;
|
||||
uint16_t port = 0;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
|
||||
if (!context || !context->internal->initialized) {
|
||||
@ -2039,6 +2042,7 @@ SMBC_getxattr_ctx(SMBCCTX *context,
|
||||
fname,
|
||||
&workgroup,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
@ -2153,6 +2157,7 @@ SMBC_removexattr_ctx(SMBCCTX *context,
|
||||
char *password = NULL;
|
||||
char *workgroup = NULL;
|
||||
char *path = NULL;
|
||||
uint16_t port = 0;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
|
||||
if (!context || !context->internal->initialized) {
|
||||
@ -2174,6 +2179,7 @@ SMBC_removexattr_ctx(SMBCCTX *context,
|
||||
fname,
|
||||
&workgroup,
|
||||
&server,
|
||||
&port,
|
||||
&share,
|
||||
&path,
|
||||
&user,
|
||||
|
Loading…
x
Reference in New Issue
Block a user