name mangling question

jra at jra at
Thu May 8 00:50:41 GMT 2003

On Tue, Apr 29, 2003 at 05:20:31PM -0700, Leo Qiu wrote:
> Jeremy,
> I have a question related to name mangling.
> In smbd/filename.c :135 (version 2.2.8a)
> if (VALID_STAT(st) && (strlen(orig_path) ==
> strlen(name)))
> I am not sure why the lengths of the original path and
> name are compared here. If the name is mangled,
> definitely this will fail and the file will be
> regarded as nonexistent because sbuf.st_nlink is equal
> to zero. If the file is regarded as nonexistent, the
> line "if (conn->vfs_ops.fchmod_acl(fsp, fsp->fd, mode)
> == -1 && errno == ENOSYS)" in smbd/nttrans.c will be
> called and the file permission is always reset to the
> inherited permission from parent directory.
> Could you please have a look at it? Thank you very
> much.

I followed the (rather tortuous :-) logic here. I think
it is ok and will never happen. If the path is mangled,
the initial stat will fail, so the one-component at a time
directory scanning code is invoked. This undoes the mangling
in the original name, and if the file exists this code
will eventually be executed :

                                 * We just scanned for, and found the end of the path.
                                 * We must return a valid stat struct if it exists.
                                 * JRA.

                                if (vfs_stat(conn,name, &st) == 0) {
                                        *pst = st;
                                } else {

This will take care of returning the valid stat struct.

Can you find a fault with this analysis, or better still do
you have a test case of it failing ?


More information about the samba-technical mailing list