Mercurial > gftp.yaz
diff lib/protocols.c @ 182:33b394ebba68
2003-6-15 Brian Masney <masneyb@gftp.org>
* lib/cache.c lib/gftp.h - added gftp_generate_cache_description().
* lib/cache.c lib/gftp.h src/text/gftp-text.c src/gtk/delete-dialog.c
src/gtk/menu-items.c src/gtk/misc-gtk.c src/gtk/mkdir-dialog.c - Added
description parameter to gftp_delete_cache_entry().
* lib/protocols.c lib/gftp.h - added gftp_fd_open(). It will call
open() and then set the socket option close on exec
* lib/cache.c lib/local.c lib/misc.c - use gftp_fd_open() instead of
open()
* lib/rfc959.c lib/protocols.c - on newly created sockets, make sure
the close on exec socket option is set
* lib/options.h src/text/gftp-text.c src/gtk/transfer.c - added
preserve_permissions option
* lib/protocols.c (gftp_parse_url) - allow an @ to be in the username
* src/text/gftp-text.c - after transfering a file, honor
preserve_permissions if it is set
* src/gtk/delete-dialog.c - improvments to clearing the expired cache
entries
author | masneyb |
---|---|
date | Sun, 15 Jun 2003 21:28:02 +0000 |
parents | 8d933999bba6 |
children | 65eb40fb4f03 |
line wrap: on
line diff
--- a/lib/protocols.c Sun Jun 15 13:22:09 2003 +0000 +++ b/lib/protocols.c Sun Jun 15 21:28:02 2003 +0000 @@ -559,7 +559,7 @@ return (0); } - if ((endhostpos = strchr (pos, '@')) != NULL) + if ((endhostpos = strrchr (pos, '@')) != NULL) { /* A user/password was entered */ if ((endpos = strchr (pos, ':')) == NULL || endhostpos < endpos) @@ -1789,6 +1789,15 @@ port = ntohs (port); #endif /* HAVE_GETADDRINFO */ + if (fcntl (sock, F_SETFD, 1) == -1) + { + request->logging_function (gftp_logging_error, request->user_data, + _("Error: Cannot set close on exec flag: %s\n"), + g_strerror (errno)); + + return (GFTP_ERETRYABLE); + } + request->logging_function (gftp_logging_misc, request->user_data, _("Connected to %s:%d\n"), connect_host, port); @@ -2370,3 +2379,39 @@ return (0); } + +int +gftp_fd_open (gftp_request * request, const char *pathname, int flags, mode_t mode) +{ + mode_t mask; + int fd; + + if (mode == 0 && (flags & O_CREAT)) + { + mask = umask (0); /* FIXME - improve */ + umask (mask); + mode = 0666 & ~mask; + } + + if ((fd = open (pathname, flags, mode)) < 0) + { + if (request != NULL) + request->logging_function (gftp_logging_error, request->user_data, + _("Error: Cannot open local file %s: %s\n"), + pathname, g_strerror (errno)); + return (GFTP_ERETRYABLE); + } + + if (fcntl (fd, F_SETFD, 1) == -1) + { + if (request != NULL) + request->logging_function (gftp_logging_error, request->user_data, + _("Error: Cannot set close on exec flag: %s\n"), + g_strerror (errno)); + + return (-1); + } + + return (fd); +} +