1
1
* utilvfs.c: ... here.
* names.h: Merge ...
* utilvfs.h: ... here.
* Makefile.am: Remove references to names.c and names.h.
Этот коммит содержится в:
Pavel Roskin 2003-10-16 16:50:09 +00:00
родитель 63740624ea
Коммит 0b99804da2
10 изменённых файлов: 87 добавлений и 114 удалений

Просмотреть файл

@ -1,5 +1,11 @@
2003-10-16 Pavel Roskin <proski@gnu.org>
* names.c: Merge ...
* utilvfs.c: ... here.
* names.h: Merge ...
* utilvfs.h: ... here.
* Makefile.am: Remove references to names.c and names.h.
* xdirentry.h: Rename vfs_s_data to vfs_s_subclass.
* cpio.c: Initialize only non-zero fields in vfs_s_subclass.
* fish.c: Likewise.

Просмотреть файл

@ -17,7 +17,6 @@ BASICFILES = \
direntry.c \
extfs.c \
local.c \
names.c \
tar.c \
sfs.c \
vfs.c
@ -28,7 +27,6 @@ VFSHDRS = \
local.h \
mcfs.h \
mcfsutil.h \
names.h \
smbfs.h \
tar.h \
tcputil.h \

Просмотреть файл

@ -25,8 +25,6 @@
/* #include "utilvfs.h" */
#include "../src/dialog.h"
/* #include "cpio.h" */
#include "names.h"
enum {
STATUS_START,

Просмотреть файл

@ -1,89 +0,0 @@
/* Look up user and/or group names.
Copyright (C) 1988, 1992 Free Software Foundation
From GNU Tar.
GNU Tar is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Tar is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
* Namespace: finduname, finduid, findgname, findgid.
*/
/*
* Look up a user or group name from a uid/gid, maintaining a cache.
* FIXME, for now it's a one-entry cache.
* FIXME2, the "-993" is to reduce the chance of a hit on the first lookup.
* This file should be modified for non-unix systems to do something
* reasonable.
*/
#include <config.h>
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <pwd.h>
#include <grp.h>
#include "names.h"
#ifndef TUNMLEN
#define TUNMLEN 256
#endif
#ifndef TGNMLEN
#define TGNMLEN 256
#endif
static int saveuid = -993;
static char saveuname[TUNMLEN];
static int my_uid = -993;
static int savegid = -993;
static char savegname[TGNMLEN];
static int my_gid = -993;
#define myuid ( my_uid < 0? (my_uid = getuid()): my_uid )
#define mygid ( my_gid < 0? (my_gid = getgid()): my_gid )
int
finduid (char *uname)
{
struct passwd *pw;
if (uname[0] != saveuname[0] /* Quick test w/o proc call */
||0 != strncmp (uname, saveuname, TUNMLEN)) {
strncpy (saveuname, uname, TUNMLEN);
pw = getpwnam (uname);
if (pw) {
saveuid = pw->pw_uid;
} else {
saveuid = myuid;
}
}
return saveuid;
}
int
findgid (char *gname)
{
struct group *gr;
if (gname[0] != savegname[0] /* Quick test w/o proc call */
||0 != strncmp (gname, savegname, TUNMLEN)) {
strncpy (savegname, gname, TUNMLEN);
gr = getgrnam (gname);
if (gr) {
savegid = gr->gr_gid;
} else {
savegid = mygid;
}
}
return savegid;
}

Просмотреть файл

@ -1,7 +0,0 @@
#ifndef __NAMES_H
#define __NAMES_H
int finduid (char *name);
int findgid (char *name);
#endif /* __NAMES_H */

Просмотреть файл

@ -29,7 +29,6 @@
#include "../src/dialog.h" /* For MSG_ERROR */
#include "tar.h"
#include "names.h"
static struct vfs_class vfs_tarfs_ops;

Просмотреть файл

@ -1,7 +1,6 @@
/* Utilities for VFS modules.
Currently includes login and tcp open socket routines.
Copyright (C) 1988, 1992 Free Software Foundation
Copyright (C) 1995, 1996 Miguel de Icaza
This program is free software; you can redistribute it and/or
@ -18,8 +17,6 @@
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Namespace: exports vfs_split_url */
#include <config.h>
#include <unistd.h>
#include <stdlib.h>
@ -36,6 +33,8 @@
#include <arpa/inet.h>
#endif
#include <errno.h>
#include <pwd.h>
#include <grp.h>
#include "utilvfs.h"
@ -146,3 +145,65 @@ vfs_split_url (const char *path, char **host, char **user, int *port,
g_free (pcopy);
return retval;
}
/*
* Look up a user or group name from a uid/gid, maintaining a cache.
* FIXME, for now it's a one-entry cache.
* FIXME2, the "-993" is to reduce the chance of a hit on the first lookup.
* This file should be modified for non-unix systems to do something
* reasonable.
*/
#ifndef TUNMLEN
#define TUNMLEN 256
#endif
#ifndef TGNMLEN
#define TGNMLEN 256
#endif
#define myuid ( my_uid < 0? (my_uid = getuid()): my_uid )
#define mygid ( my_gid < 0? (my_gid = getgid()): my_gid )
int
finduid (char *uname)
{
static int saveuid = -993;
static char saveuname[TUNMLEN];
static int my_uid = -993;
struct passwd *pw;
if (uname[0] != saveuname[0] /* Quick test w/o proc call */
||0 != strncmp (uname, saveuname, TUNMLEN)) {
strncpy (saveuname, uname, TUNMLEN);
pw = getpwnam (uname);
if (pw) {
saveuid = pw->pw_uid;
} else {
saveuid = myuid;
}
}
return saveuid;
}
int
findgid (char *gname)
{
static int savegid = -993;
static char savegname[TGNMLEN];
static int my_gid = -993;
struct group *gr;
if (gname[0] != savegname[0] /* Quick test w/o proc call */
||0 != strncmp (gname, savegname, TUNMLEN)) {
strncpy (savegname, gname, TUNMLEN);
gr = getgrnam (gname);
if (gr) {
savegid = gr->gr_gid;
} else {
savegid = mygid;
}
}
return savegid;
}

Просмотреть файл

@ -1,6 +1,21 @@
#ifndef __UTILVFS_H
#define __UTILVFS_H
#include "../src/global.h"
#include "../src/tty.h" /* enable/disable interrupt key */
#include "../src/wtools.h" /* MSG_ERROR */
#include "../src/background.h" /* message_1s */
#include "../src/background.h" /* message_1s */
#include "../src/main.h" /* print_vfs_message */
/* Flags for vfs_split_url() */
#define URL_ALLOW_ANON 1
#define URL_NOSLASH 2
char *vfs_split_url (const char *path, char **host, char **user, int *port,
char **pass, int default_port, int flags);
int finduid (char *name);
int findgid (char *name);
#endif /* !__UTILVFS_H */

Просмотреть файл

@ -49,7 +49,6 @@
#include "vfs.h"
#include "extfs.h" /* FIXME: we should not know anything about our modules */
#include "names.h"
#ifdef USE_NETCODE
# include "tcputil.h"
#endif

Просмотреть файл

@ -201,13 +201,6 @@ int vfs_parse_filedate (int idx, time_t * t);
void vfs_die (const char *msg);
char *vfs_get_password (char *msg);
/* Flags for vfs_split_url() */
#define URL_ALLOW_ANON 1
#define URL_NOSLASH 2
char *vfs_split_url (const char *path, char **host, char **user, int *port,
char **pass, int default_port, int flags);
#ifdef WITH_SMBFS
/* Interface for requesting SMB credentials. */
struct smb_authinfo {