summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/includes.h25
-rw-r--r--source3/include/proto.h19
-rw-r--r--source3/include/smb.h16
-rw-r--r--source3/lib/system.c169
-rw-r--r--source3/script/mkproto.awk2
5 files changed, 224 insertions, 7 deletions
diff --git a/source3/include/includes.h b/source3/include/includes.h
index e8eb8e28ea..b42f5e0115 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -649,6 +649,31 @@ extern int errno;
#define MAXCODEPAGELINES 256
#endif
+/*
+ * Type for wide character dirent structure.
+ */
+
+typedef struct smb_wdirent {
+ SMB_INO_T d_ino;
+ SMB_OFF_T d_off;
+ unsigned short d_reclen;
+ wpstring d_name;
+} SMB_STRUCT_WDIRENT;
+
+/*
+ * Type for wide character passwd structure.
+ */
+
+typedef struct smb_wpasswd {
+ wfstring pw_name;
+ char *pw_passwd;
+ uid_t pw_uid;
+ gid_t pw_gid;
+ wpstring pw_gecos;
+ wpstring pw_dir;
+ wpstring pw_shell;
+} SMB_STRUCT_WPASSWD;
+
/***** automatically generated prototypes *****/
#include "proto.h"
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 79abdf5f56..18762c32fb 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -182,6 +182,15 @@ int sys_getgroups(int setlen, gid_t *gidset);
int sys_setgroups(int setlen, gid_t *gidset);
struct passwd *sys_getpwnam(const char *name);
struct passwd *sys_getpwuid(uid_t uid);
+int wsys_stat(const smb_ucs2_t *wfname,SMB_STRUCT_STAT *sbuf);
+int wsys_lstat(const smb_ucs2_t *wfname,SMB_STRUCT_STAT *sbuf);
+int wsys_creat(const smb_ucs2_t *wfname, mode_t mode);
+int wsys_open(const smb_ucs2_t *wfname, int oflag, mode_t mode);
+FILE *wsys_fopen(const smb_ucs2_t *wfname, const char *type);
+DIR *wsys_opendir(const smb_ucs2_t *wfname);
+smb_ucs2_t *wsys_getwd(smb_ucs2_t *s);
+int wsys_chown(const smb_ucs2_t *wfname, uid_t uid, gid_t gid);
+int wsys_chroot(const smb_ucs2_t *wfname);
/*The following definitions come from lib/time.c */
@@ -423,11 +432,21 @@ void default_unicode_map(smb_ucs2_t **pp_cp_to_ucs2, uint16 **pp_ucs2_to_cp);
BOOL load_unicode_map(const char *codepage, smb_ucs2_t **pp_cp_to_ucs2, uint16 **pp_ucs2_to_cp);
BOOL load_dos_unicode_map(int codepage);
BOOL load_unix_unicode_map(const char *unix_char_set);
+smb_ucs2_t *multibyte_to_unicode(smb_ucs2_t *dst, const char *src,
+ size_t dst_len, smb_ucs2_t *cp_to_ucs2);
char *unicode_to_unix(char *dst, const smb_ucs2_t *src, size_t dst_len);
+smb_ucs2_t *unix_to_unicode(smb_ucs2_t *dst, const char *src, size_t dst_len);
char *unicode_to_dos(char *dst, const smb_ucs2_t *src, size_t dst_len);
+smb_ucs2_t *dos_to_unicode(smb_ucs2_t *dst, const char *src, size_t dst_len);
size_t wstrlen(const smb_ucs2_t *src);
+smb_ucs2_t *safe_wstrcpy(smb_ucs2_t *dest,const smb_ucs2_t *src, size_t maxlength);
+smb_ucs2_t *safe_wstrcat(smb_ucs2_t *dest, const smb_ucs2_t *src, size_t maxlength);
int wstrcmp(const smb_ucs2_t *s1, const smb_ucs2_t *s2);
int wstrncmp(const smb_ucs2_t *s1, const smb_ucs2_t *s2, size_t len);
+smb_ucs2_t *wstrstr(const smb_ucs2_t *s1, const smb_ucs2_t *s2);
+smb_ucs2_t *wstrchr(const smb_ucs2_t *s, smb_ucs2_t c);
+smb_ucs2_t *wstrrchr(const smb_ucs2_t *s, smb_ucs2_t c);
+smb_ucs2_t *wstrtok(smb_ucs2_t *s1, const smb_ucs2_t *s2);
/*The following definitions come from libsmb/clientgen.c */
diff --git a/source3/include/smb.h b/source3/include/smb.h
index de269f1d7d..ec1aaf2273 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -333,6 +333,16 @@ implemented */
typedef char pstring[1024];
typedef char fstring[128];
+/*
+ * SMB UCS2 (16-bit unicode) internal type.
+ */
+
+typedef uint16 smb_ucs2_t;
+
+/* ucs2 string types. */
+typedef smb_ucs2_t wpstring[1024];
+typedef smb_ucs2_t wfstring[128];
+
/* pipe string names */
#define PIPE_LANMAN "\\PIPE\\LANMAN"
#define PIPE_SRVSVC "\\PIPE\\srvsvc"
@@ -1792,10 +1802,4 @@ struct nmb_name {
#define MAP_TO_GUEST_ON_BAD_USER 1
#define MAP_TO_GUEST_ON_BAD_PASSWORD 2
-/*
- * SMB UCS2 (16-bit unicode) internal type.
- */
-
-typedef uint16 smb_ucs2_t;
-
#endif /* _SMB_H */
diff --git a/source3/lib/system.c b/source3/lib/system.c
index a59f94a6a9..710f30bac8 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -722,3 +722,172 @@ struct passwd *sys_getpwuid(uid_t uid)
{
return setup_pwret(getpwuid(uid));
}
+
+/**************************************************************************
+ The following are the UNICODE versions of *all* system interface functions
+ called within Samba. Ok, ok, the exceptions are the gethostbyXX calls,
+ which currently are left as ascii as they are not used other than in name
+ resolution.
+****************************************************************************/
+
+/**************************************************************************
+ Wide stat. Just narrow and call sys_xxx.
+****************************************************************************/
+
+int wsys_stat(const smb_ucs2_t *wfname,SMB_STRUCT_STAT *sbuf)
+{
+ pstring fname;
+ return sys_stat(unicode_to_unix(fname,wfname,sizeof(fname)), sbuf);
+}
+
+/**************************************************************************
+ Wide lstat. Just narrow and call sys_xxx.
+****************************************************************************/
+
+int wsys_lstat(const smb_ucs2_t *wfname,SMB_STRUCT_STAT *sbuf)
+{
+ pstring fname;
+ return sys_lstat(unicode_to_unix(fname,wfname,sizeof(fname)), sbuf);
+}
+
+/**************************************************************************
+ Wide creat. Just narrow and call sys_xxx.
+****************************************************************************/
+
+int wsys_creat(const smb_ucs2_t *wfname, mode_t mode)
+{
+ pstring fname;
+ return sys_creat(unicode_to_unix(fname,wfname,sizeof(fname)), mode);
+}
+
+/**************************************************************************
+ Wide open. Just narrow and call sys_xxx.
+****************************************************************************/
+
+int wsys_open(const smb_ucs2_t *wfname, int oflag, mode_t mode)
+{
+ pstring fname;
+ return sys_open(unicode_to_unix(fname,wfname,sizeof(fname)), oflag, mode);
+}
+
+/**************************************************************************
+ Wide fopen. Just narrow and call sys_xxx.
+****************************************************************************/
+
+FILE *wsys_fopen(const smb_ucs2_t *wfname, const char *type)
+{
+ pstring fname;
+ return sys_fopen(unicode_to_unix(fname,wfname,sizeof(fname)), type);
+}
+
+/**************************************************************************
+ Wide opendir. Just narrow and call sys_xxx.
+****************************************************************************/
+
+DIR *wsys_opendir(const smb_ucs2_t *wfname)
+{
+ pstring fname;
+ return opendir(unicode_to_unix(fname,wfname,sizeof(fname)));
+}
+
+/**************************************************************************
+ Wide readdir. Return a structure pointer containing a wide filename.
+****************************************************************************/
+
+SMB_STRUCT_WDIRENT *wsys_readdir(DIR *dirp)
+{
+ static SMB_STRUCT_WDIRENT retval;
+ SMB_STRUCT_DIRENT *dirval = sys_readdir(dirp);
+
+ if(!dirval)
+ return NULL;
+
+ retval.d_ino = (SMB_INO_T)dirval->d_ino;
+ retval.d_off = (SMB_OFF_T)dirval->d_off;
+ unix_to_unicode(retval.d_name,dirval->d_name,sizeof(retval.d_name));
+ retval.d_reclen = wstrlen(retval.d_name);
+
+ return &retval;
+}
+
+/**************************************************************************
+ Wide getwd. Call sys_xxx and widen. Assumes s points to a wpstring.
+****************************************************************************/
+
+smb_ucs2_t *wsys_getwd(smb_ucs2_t *s)
+{
+ pstring fname;
+ char *p = sys_getwd(fname);
+
+ if(!p)
+ return NULL;
+
+ return unix_to_unicode(s, p, sizeof(wpstring));
+}
+
+/**************************************************************************
+ Wide chown. Just narrow and call sys_xxx.
+****************************************************************************/
+
+int wsys_chown(const smb_ucs2_t *wfname, uid_t uid, gid_t gid)
+{
+ pstring fname;
+ return chown(unicode_to_unix(fname,wfname,sizeof(fname)), uid, gid);
+}
+
+/**************************************************************************
+ Wide chroot. Just narrow and call sys_xxx.
+****************************************************************************/
+
+int wsys_chroot(const smb_ucs2_t *wfname)
+{
+ pstring fname;
+ return chroot(unicode_to_unix(fname,wfname,sizeof(fname)));
+}
+
+/**************************************************************************
+ Wide getpwnam. Return a structure pointer containing wide names.
+****************************************************************************/
+
+SMB_STRUCT_WPASSWD *wsys_getpwnam(const smb_ucs2_t *wname)
+{
+ static SMB_STRUCT_WPASSWD retval;
+ fstring name;
+ struct passwd *pwret = sys_getpwnam(unicode_to_unix(name,wname,sizeof(name)));
+
+ if(!pwret)
+ return NULL;
+
+ unix_to_unicode(retval.pw_name, pwret->pw_name, sizeof(retval.pw_name));
+ retval.pw_passwd = pwret->pw_passwd;
+ retval.pw_uid = pwret->pw_uid;
+ retval.pw_gid = pwret->pw_gid;
+ unix_to_unicode(retval.pw_gecos, pwret->pw_gecos, sizeof(retval.pw_gecos));
+ unix_to_unicode(retval.pw_dir, pwret->pw_dir, sizeof(retval.pw_dir));
+ unix_to_unicode(retval.pw_shell, pwret->pw_shell, sizeof(retval.pw_shell));
+
+ return &retval;
+}
+
+/**************************************************************************
+ Wide getpwuid. Return a structure pointer containing wide names.
+****************************************************************************/
+
+SMB_STRUCT_WPASSWD *wsys_getpwuid(uid_t uid)
+{
+ static SMB_STRUCT_WPASSWD retval;
+ struct passwd *pwret = sys_getpwuid(uid);
+
+ if(!pwret)
+ return NULL;
+
+ unix_to_unicode(retval.pw_name, pwret->pw_name, sizeof(retval.pw_name));
+ retval.pw_passwd = pwret->pw_passwd;
+ retval.pw_uid = pwret->pw_uid;
+ retval.pw_gid = pwret->pw_gid;
+ unix_to_unicode(retval.pw_gecos, pwret->pw_gecos, sizeof(retval.pw_gecos));
+ unix_to_unicode(retval.pw_dir, pwret->pw_dir, sizeof(retval.pw_dir));
+ unix_to_unicode(retval.pw_shell, pwret->pw_shell, sizeof(retval.pw_shell));
+
+ return &retval;
+}
diff --git a/source3/script/mkproto.awk b/source3/script/mkproto.awk
index fd0cbcd2f8..c24dfac98c 100644
--- a/source3/script/mkproto.awk
+++ b/source3/script/mkproto.awk
@@ -98,7 +98,7 @@ END {
gotstart = 1;
}
- if( $0 ~ /^TDB_CONTEXT|^TDB_DATA/ ) {
+ if( $0 ~ /^TDB_CONTEXT|^TDB_DATA|^smb_ucs2_t/ ) {
gotstart = 1;
}