- ret = SMB_VFS_NEXT_STAT(handle, fname, sbuf);
- if (ret == 0) {
- if (S_ISDIR(sbuf->st_mode)) {
- sbuf->st_mode = S_IFDIR | S_IRWXU;
- } else {
- sbuf->st_mode = S_IRWXU;
- }
- sbuf->st_uid = current_user.ut.uid;
- sbuf->st_gid = current_user.ut.gid;
+ if (S_ISDIR(smb_fname->st.st_ex_mode)) {
+ smb_fname->st.st_ex_mode = S_IFDIR | S_IRWXU;
+ } else {
+ smb_fname->st.st_ex_mode = S_IRWXU;
+ }
+
+ if (handle->conn->session_info != NULL) {
+ struct security_unix_token *utok;
+
+ utok = handle->conn->session_info->unix_token;
+ smb_fname->st.st_ex_uid = utok->uid;
+ smb_fname->st.st_ex_gid = utok->gid;
+ } else {
+ /*
+ * We have an artificial connection for dfs for example. It
+ * sucks, but the current uid/gid is the best we have.
+ */
+ smb_fname->st.st_ex_uid = geteuid();
+ smb_fname->st.st_ex_gid = getegid();