perhaps POSIX fcntl() should be used instead of flock() for setting file locking options, at least for SunOS

Need help with FileZilla Client? Something does not work as expected? In this forum you may find an answer.

Moderator: Project members

Post Reply
Message
Author
risto3
500 Syntax error
Posts: 12
Joined: 2015-07-07 17:03
First name: Richard
Last name: PALO

perhaps POSIX fcntl() should be used instead of flock() for setting file locking options, at least for SunOS

#1 Post by risto3 » 2015-07-08 20:12

Please find the patch needed to complete the build on SunOS:

Code: Select all

--- src/putty/unix/uxshare.c.orig       2014-12-18 15:15:44.000000000 +0000
+++ src/putty/unix/uxshare.c
@@ -295,6 +295,13 @@ int platform_ssh_share(const char *pi_na
     int lockfd;
     Socket retsock;
 
+    struct flock lock;
+
+    lock.l_type = F_WRLCK;
+    lock.l_whence = SEEK_SET;
+    lock.l_start = 0;
+    lock.l_len = 0;
+
     /*
      * Sort out what we're going to call the directory in which we
      * keep the socket. This has the side effect of potentially
@@ -326,9 +333,15 @@ int platform_ssh_share(const char *pi_na
         sfree(lockname);
         return SHARE_NONE;
     }
+#ifdef __sun
+    if (fcntl(lockfd, F_SETLK, &lock) == -1) {
+        *logtext = dupprintf("%s: fcntl(F_SETLK): %s",
+                             lockname, strerror(errno));
+#else
     if (flock(lockfd, LOCK_EX) < 0) {
         *logtext = dupprintf("%s: flock(LOCK_EX): %s",
                              lockname, strerror(errno));
+#endif
         sfree(dirname);
         sfree(lockname);
         close(lockfd);


User avatar
botg
Site Admin
Posts: 33233
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse
Contact:

Re: perhaps POSIX fcntl() should be used instead of flock() for setting file locking options, at least for SunOS

#2 Post by botg » 2015-07-08 21:54

Hmm, that's in PuTTY code. I wonder why PuTTY uses flock at all instead of fcntl.

Sadly unconditionally changing it to fcntl is problematic if one were to run unchanged and changed versions on the same platform :(

I'll bring this up for discussion on the PuTTY mailinglist.

awatkins1966
500 Command not understood
Posts: 2
Joined: 2018-04-24 15:59
First name: Andrew
Last name: Watkins

Re: perhaps POSIX fcntl() should be used instead of flock() for setting file locking options, at least for SunOS

#3 Post by awatkins1966 » 2018-04-24 16:02

Thanks for the patch to get FileZilla client working on Oracle Solaris 11.4.

Yes, it would be great if this code could find it's way into putty.

Thanks

User avatar
boco
Contributor
Posts: 25325
Joined: 2006-05-01 03:28
Location: Germany

Re: perhaps POSIX fcntl() should be used instead of flock() for setting file locking options, at least for SunOS

#4 Post by boco » 2018-04-25 01:59

Given the date of the last post, it could be in, already.
### BEGIN SIGNATURE BLOCK ###
No support requests per PM! You will NOT get any reply!!!
FTP connection problems? Do yourself a favor and read Network Configuration.
FileZilla connection test: https://filezilla-project.org/conntest.php
### END SIGNATURE BLOCK ###

awatkins1966
500 Command not understood
Posts: 2
Joined: 2018-04-24 15:59
First name: Andrew
Last name: Watkins

Re: perhaps POSIX fcntl() should be used instead of flock() for setting file locking options, at least for SunOS

#5 Post by awatkins1966 » 2018-04-25 16:24

Nope!
Checked latest putty version and it has the old version in it. So, still waiting for putty to be updated.

Post Reply