* bug#55855: "Invalid file name" error with tramp-smb filename check
@ 2022-06-08 17:55 Evan MacTaggart
2022-06-09 12:51 ` Michael Albinus
0 siblings, 1 reply; 4+ messages in thread
From: Evan MacTaggart @ 2022-06-08 17:55 UTC (permalink / raw)
To: 55855
[-- Attachment #1: Type: text/plain, Size: 2147 bytes --]
So after tramping into an SMB file server, I'm trying to find-file into a
directory whose name is as so: "/smb:username%DOMAIN@fsname:/my path/1234.
Some Name". The problem with this filename is that the filename contains a
". ", which throws a tramp-error. And as per the code comment is "not
supported", however it seems as though, at least for the server I'm
connected to, this is supported.
I'm certainly not the most well versed on the samba protocol, but perhaps
look into this and see if the once invalid file names are now valid. Or
perhaps describe specifically what is not supported about this filename.
I'd imagine/assume this is due to a newer SMB version than what the
following code was initially written for.
The following is where the check happens,
```
;; /28.1/lisp/net/tramp-smb.el.gz ;;
(defun tramp-smb-get-localname (vec)
"Return the file name of LOCALNAME.
If VEC has no cifs capabilities, exchange \"/\" by \"\\\\\"."
(save-match-data
(let ((localname (tramp-file-name-unquote-localname vec)))
(setq
localname
(if (string-match "^/?[^/]+\\(/.*\\)" localname)
;; There is a share, separated by "/".
(if (not (tramp-smb-get-cifs-capabilities vec))
(mapconcat
(lambda (x) (if (equal x ?/) "\\" (char-to-string x)))
(match-string 1 localname) "")
(match-string 1 localname))
;; There is just a share.
(if (string-match "^/?\\([^/]+\\)$" localname)
(match-string 1 localname)
"")))
;; Sometimes we have discarded `substitute-in-file-name'.
(when (string-match "\\(\\$\\$\\)\\(/\\|$\\)" localname)
(setq localname (replace-match "$" nil nil localname 1)))
;; A period followed by a space, or trailing periods and spaces,
;; are not supported.
(when (string-match-p "\\. \\|\\.$\\| $" localname) ;; <<<< THIS
CHECK HERE <<<<<
(tramp-error
vec 'file-error
"Invalid file name %s" (tramp-make-tramp-file-name vec localname)))
localname)))
```
My work around for this was to redefine tramp-smb-get-localname with looser
filename checking.
Thanks in advance, and let me know if there's anything else you need from
me.
Cheers,
Evan MacTaggart
[-- Attachment #2: Type: text/html, Size: 2829 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#55855: "Invalid file name" error with tramp-smb filename check
2022-06-08 17:55 bug#55855: "Invalid file name" error with tramp-smb filename check Evan MacTaggart
@ 2022-06-09 12:51 ` Michael Albinus
2022-06-09 16:24 ` Evan MacTaggart
0 siblings, 1 reply; 4+ messages in thread
From: Michael Albinus @ 2022-06-09 12:51 UTC (permalink / raw)
To: Evan MacTaggart; +Cc: 55855
Evan MacTaggart <evan.mactaggart@gmail.com> writes:
Hi Evan,
> So after tramping into an SMB file server, I'm trying to find-file
> into a directory whose name is as so: "/smb:username%DOMAIN@fsname:/my
> path/1234. Some Name". The problem with this filename is that the
> filename contains a ". ", which throws a tramp-error. And as per the
> code comment is "not supported", however it seems as though, at least
> for the server I'm connected to, this is supported.
Thanks for the report and the analysis!
> I'm certainly not the most well versed on the samba protocol, but
> perhaps look into this and see if the once invalid file names are now
> valid. Or perhaps describe specifically what is not supported about
> this filename. I'd imagine/assume this is due to a newer SMB version
> than what the following code was initially written for.
I've digged into this, and you are right: There is no SMB protocol
problem. There is an error in tramp-smb-handle-write-region, which
didn't quote tmpfile when sending "put ...". Since it wasn't detected
earlier, it was regarded as problem of SMB, resulting in the wrong
check.
I've fixed this now, and I've also adapted the check in
tramp-smb-get-localname. Pushed to the emacs-28 git branch. Will appear
with Emacs 28.2 as well as with the next GNU ELPA Tramp release (2.5.3
or 2.6.0, not decided yet).
> Thanks in advance, and let me know if there's anything else you need
> from me.
You could test with the emacs-28 git branch. For the master branch, I
haven't pushed a fix yet, because I'd like to rework it for being more
robust. If you don't use a git clone, you can consult the patch at
<https://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-28&id=3fd08543782d0d417eaa2dda0727ea16b3271710>. Does
it work for you as well?
> Cheers,
> Evan MacTaggart
Best regards, Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#55855: "Invalid file name" error with tramp-smb filename check
2022-06-09 12:51 ` Michael Albinus
@ 2022-06-09 16:24 ` Evan MacTaggart
2022-06-09 16:48 ` Michael Albinus
0 siblings, 1 reply; 4+ messages in thread
From: Evan MacTaggart @ 2022-06-09 16:24 UTC (permalink / raw)
To: Michael Albinus; +Cc: 55855
[-- Attachment #1: Type: text/plain, Size: 2343 bytes --]
Hey Michael,
I gave your changes a rip (via the latest emacs-28 branch
(22a832ad82ed7d099e6ee3a947a5841d84e475c4)) and they worked like a charm! I
was able to open/save/copy/move/delete both files and directories with
names containing ". ". Thanks for the speedy response and the quick fix,
you are awesome!
Cheers,
Evan MacTaggart
On Thu, Jun 9, 2022 at 6:51 AM Michael Albinus <michael.albinus@gmx.de>
wrote:
> Evan MacTaggart <evan.mactaggart@gmail.com> writes:
>
> Hi Evan,
>
> > So after tramping into an SMB file server, I'm trying to find-file
> > into a directory whose name is as so: "/smb:username%DOMAIN@fsname:/my
> > path/1234. Some Name". The problem with this filename is that the
> > filename contains a ". ", which throws a tramp-error. And as per the
> > code comment is "not supported", however it seems as though, at least
> > for the server I'm connected to, this is supported.
>
> Thanks for the report and the analysis!
>
> > I'm certainly not the most well versed on the samba protocol, but
> > perhaps look into this and see if the once invalid file names are now
> > valid. Or perhaps describe specifically what is not supported about
> > this filename. I'd imagine/assume this is due to a newer SMB version
> > than what the following code was initially written for.
>
> I've digged into this, and you are right: There is no SMB protocol
> problem. There is an error in tramp-smb-handle-write-region, which
> didn't quote tmpfile when sending "put ...". Since it wasn't detected
> earlier, it was regarded as problem of SMB, resulting in the wrong
> check.
>
> I've fixed this now, and I've also adapted the check in
> tramp-smb-get-localname. Pushed to the emacs-28 git branch. Will appear
> with Emacs 28.2 as well as with the next GNU ELPA Tramp release (2.5.3
> or 2.6.0, not decided yet).
>
> > Thanks in advance, and let me know if there's anything else you need
> > from me.
>
> You could test with the emacs-28 git branch. For the master branch, I
> haven't pushed a fix yet, because I'd like to rework it for being more
> robust. If you don't use a git clone, you can consult the patch at
> <
> https://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-28&id=3fd08543782d0d417eaa2dda0727ea16b3271710>.
> Does
> it work for you as well?
>
> > Cheers,
> > Evan MacTaggart
>
> Best regards, Michael.
>
[-- Attachment #2: Type: text/html, Size: 3322 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#55855: "Invalid file name" error with tramp-smb filename check
2022-06-09 16:24 ` Evan MacTaggart
@ 2022-06-09 16:48 ` Michael Albinus
0 siblings, 0 replies; 4+ messages in thread
From: Michael Albinus @ 2022-06-09 16:48 UTC (permalink / raw)
To: Evan MacTaggart; +Cc: 55855-done
Version: 28.2
Evan MacTaggart <evan.mactaggart@gmail.com> writes:
> Hey Michael,
Hi Evan,
> I gave your changes a rip (via the latest emacs-28 branch
> (22a832ad82ed7d099e6ee3a947a5841d84e475c4)) and they worked like a
> charm! I was able to open/save/copy/move/delete both files and
> directories with names containing ". ". Thanks for the speedy response
> and the quick fix, you are awesome!
Thanks for the feedback! I'm closing the bug then.
> Cheers,
> Evan MacTaggart
Best regards, Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-06-09 16:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-08 17:55 bug#55855: "Invalid file name" error with tramp-smb filename check Evan MacTaggart
2022-06-09 12:51 ` Michael Albinus
2022-06-09 16:24 ` Evan MacTaggart
2022-06-09 16:48 ` Michael Albinus
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).