mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
* vfs/smbfs.c: Rename authinfo to smb_authinfo and
authinfo_get_authinfo_from_user() to vfs_smb_get_authinfo() and remove their definitions. * vfs/vfs.h: Declare smb_authinfo and vfs_smb_get_authinfo().
This commit is contained in:
parent
74f034e8d4
commit
820a35758e
@ -1,3 +1,10 @@
|
||||
2001-07-15 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* vfs/smbfs.c: Rename authinfo to smb_authinfo and
|
||||
authinfo_get_authinfo_from_user() to vfs_smb_get_authinfo()
|
||||
and remove their definitions.
|
||||
* vfs/vfs.h: Declare smb_authinfo and vfs_smb_get_authinfo().
|
||||
|
||||
2001-07-10 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* extfs.c: Include contents of shared_tar_ext.c - it's no
|
||||
|
149
vfs/smbfs.c
149
vfs/smbfs.c
@ -40,9 +40,6 @@
|
||||
#include "smbfs.h"
|
||||
#include "tcputil.h"
|
||||
#include "../src/dialog.h"
|
||||
#include "../src/widget.h"
|
||||
#include "../src/color.h"
|
||||
#include "../src/wtools.h"
|
||||
|
||||
#define SMBFS_MAX_CONNECTIONS 16
|
||||
static const char * const IPC = "IPC$";
|
||||
@ -89,128 +86,10 @@ typedef struct {
|
||||
uint16 attr;
|
||||
} smbfs_handle;
|
||||
|
||||
struct authinfo {
|
||||
char *host;
|
||||
char *share;
|
||||
char *domain;
|
||||
char *user;
|
||||
char *password;
|
||||
/* struct timeval timestamp;*/
|
||||
};
|
||||
|
||||
static GSList *auth_list;
|
||||
|
||||
static struct authinfo *
|
||||
authinfo_get_authinfo_from_user (const char *host,
|
||||
const char *share,
|
||||
const char *domain,
|
||||
const char *user)
|
||||
{
|
||||
static int dialog_x = 44;
|
||||
int dialog_y = 12;
|
||||
struct authinfo *return_value;
|
||||
static char* labs[] = {N_("Domain:"), N_("Username:"), N_("Password: ")};
|
||||
static char* buts[] = {N_("&Ok"), N_("&Cancel")};
|
||||
static int ilen = 30, istart = 14;
|
||||
static int b0 = 3, b2 = 30;
|
||||
char *title;
|
||||
WInput *in_password;
|
||||
WInput *in_user;
|
||||
WInput *in_domain;
|
||||
Dlg_head *auth_dlg;
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
static int i18n_flag = 0;
|
||||
|
||||
if (!i18n_flag)
|
||||
{
|
||||
register int i = sizeof(labs)/sizeof(labs[0]);
|
||||
int l1, maxlen = 0;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
l1 = strlen (labs [i] = _(labs [i]));
|
||||
if (l1 > maxlen)
|
||||
maxlen = l1;
|
||||
}
|
||||
i = maxlen + ilen + 7;
|
||||
if (i > dialog_x)
|
||||
dialog_x = i;
|
||||
|
||||
for (i = sizeof(buts)/sizeof(buts[0]), l1 = 0; i--; )
|
||||
{
|
||||
l1 += strlen (buts [i] = _(buts [i]));
|
||||
}
|
||||
l1 += 15;
|
||||
if (l1 > dialog_x)
|
||||
dialog_x = l1;
|
||||
|
||||
ilen = dialog_x - 7 - maxlen; /* for the case of very long buttons :) */
|
||||
istart = dialog_x - 3 - ilen;
|
||||
|
||||
b2 = dialog_x - (strlen(buts[1]) + 6);
|
||||
|
||||
i18n_flag = 1;
|
||||
}
|
||||
|
||||
#endif /* ENABLE_NLS */
|
||||
|
||||
if (!domain)
|
||||
domain = "";
|
||||
if (!user)
|
||||
user = "";
|
||||
|
||||
auth_dlg = create_dlg (0, 0, dialog_y, dialog_x, dialog_colors,
|
||||
common_dialog_callback, "[Smb Authinfo]", "smbauthinfo",
|
||||
DLG_CENTER | DLG_GRID);
|
||||
|
||||
title = g_strdup_printf (_("Password for \\\\%s\\%s"), host, share);
|
||||
x_set_dialog_title (auth_dlg, title);
|
||||
g_free (title);
|
||||
|
||||
in_user = input_new (5, istart, INPUT_COLOR, ilen, user, "auth_name");
|
||||
add_widget (auth_dlg, in_user);
|
||||
|
||||
in_domain = input_new (3, istart, INPUT_COLOR, ilen, domain, "auth_domain");
|
||||
add_widget (auth_dlg, in_domain);
|
||||
add_widget (auth_dlg, button_new (9, b2, B_CANCEL, NORMAL_BUTTON,
|
||||
buts[1], 0 ,0, "cancel"));
|
||||
add_widget (auth_dlg, button_new (9, b0, B_ENTER, DEFPUSH_BUTTON,
|
||||
buts[0], 0, 0, "ok"));
|
||||
|
||||
in_password = input_new (7, istart, INPUT_COLOR, ilen, "", "auth_password");
|
||||
in_password->completion_flags = 0;
|
||||
in_password->is_password = 1;
|
||||
add_widget (auth_dlg, in_password);
|
||||
|
||||
add_widget (auth_dlg, label_new (7, 3, labs[2], "label-passwd"));
|
||||
add_widget (auth_dlg, label_new (5, 3, labs[1], "label-user"));
|
||||
add_widget (auth_dlg, label_new (3, 3, labs[0], "label-domain"));
|
||||
|
||||
run_dlg (auth_dlg);
|
||||
|
||||
switch (auth_dlg->ret_value) {
|
||||
case B_CANCEL:
|
||||
return_value = 0;
|
||||
break;
|
||||
default:
|
||||
return_value = g_new (struct authinfo, 1);
|
||||
if (return_value) {
|
||||
return_value->host = g_strdup (host);
|
||||
return_value->share = g_strdup (share);
|
||||
return_value->domain = g_strdup (in_domain->buffer);
|
||||
return_value->user = g_strdup (in_user->buffer);
|
||||
return_value->password = g_strdup (in_password->buffer);
|
||||
}
|
||||
}
|
||||
|
||||
destroy_dlg (auth_dlg);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
static void
|
||||
authinfo_free (struct authinfo const *a)
|
||||
authinfo_free (struct smb_authinfo const *a)
|
||||
{
|
||||
g_free (a->host);
|
||||
g_free (a->share);
|
||||
@ -232,8 +111,8 @@ authinfo_free_all ()
|
||||
static gint
|
||||
authinfo_compare_host_and_share (gconstpointer _a, gconstpointer _b)
|
||||
{
|
||||
struct authinfo const *a = (struct authinfo const *)_a;
|
||||
struct authinfo const *b = (struct authinfo const *)_b;
|
||||
struct smb_authinfo const *a = (struct smb_authinfo const *)_a;
|
||||
struct smb_authinfo const *b = (struct smb_authinfo const *)_b;
|
||||
|
||||
if (!a->host || !a->share || !b->host || !b->share)
|
||||
return 1;
|
||||
@ -247,8 +126,8 @@ authinfo_compare_host_and_share (gconstpointer _a, gconstpointer _b)
|
||||
static gint
|
||||
authinfo_compare_host (gconstpointer _a, gconstpointer _b)
|
||||
{
|
||||
struct authinfo const *a = (struct authinfo const *)_a;
|
||||
struct authinfo const *b = (struct authinfo const *)_b;
|
||||
struct smb_authinfo const *a = (struct smb_authinfo const *)_a;
|
||||
struct smb_authinfo const *b = (struct smb_authinfo const *)_b;
|
||||
|
||||
if (!a->host || !b->host)
|
||||
return 1;
|
||||
@ -263,7 +142,7 @@ static void
|
||||
authinfo_add (const char *host, const char *share, const char *domain,
|
||||
const char *user, const char *password)
|
||||
{
|
||||
struct authinfo *auth = g_new (struct authinfo, 1);
|
||||
struct smb_authinfo *auth = g_new (struct smb_authinfo, 1);
|
||||
|
||||
if (!auth)
|
||||
return;
|
||||
@ -280,8 +159,8 @@ authinfo_add (const char *host, const char *share, const char *domain,
|
||||
static void
|
||||
authinfo_remove (const char *host, const char *share)
|
||||
{
|
||||
struct authinfo data;
|
||||
struct authinfo *auth;
|
||||
struct smb_authinfo data;
|
||||
struct smb_authinfo *auth;
|
||||
GSList *list;
|
||||
|
||||
data.host = g_strdup (host);
|
||||
@ -306,8 +185,8 @@ bucket_set_authinfo (smbfs_connection *bucket,
|
||||
const char *domain, const char *user, const char *pass,
|
||||
int fallback_to_host)
|
||||
{
|
||||
struct authinfo data;
|
||||
struct authinfo *auth;
|
||||
struct smb_authinfo data;
|
||||
struct smb_authinfo *auth;
|
||||
GSList *list;
|
||||
|
||||
if (domain && user && pass) {
|
||||
@ -343,10 +222,10 @@ bucket_set_authinfo (smbfs_connection *bucket,
|
||||
return 1;
|
||||
}
|
||||
|
||||
auth = authinfo_get_authinfo_from_user (bucket->host,
|
||||
bucket->service,
|
||||
(domain ? domain : lp_workgroup ()),
|
||||
user);
|
||||
auth = vfs_smb_get_authinfo (bucket->host,
|
||||
bucket->service,
|
||||
(domain ? domain : lp_workgroup ()),
|
||||
user);
|
||||
if (auth) {
|
||||
g_free (bucket->domain);
|
||||
g_free (bucket->user);
|
||||
|
16
vfs/vfs.h
16
vfs/vfs.h
@ -349,6 +349,22 @@ extern void vfs_die (char *msg);
|
||||
extern char *vfs_get_password (char *msg);
|
||||
extern char *vfs_split_url (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 {
|
||||
char *host;
|
||||
char *share;
|
||||
char *domain;
|
||||
char *user;
|
||||
char *password;
|
||||
};
|
||||
|
||||
struct smb_authinfo *
|
||||
vfs_smb_get_authinfo (const char *host, const char *share, const char *domain,
|
||||
const char *user);
|
||||
#endif /* WITH_SMBFS */
|
||||
|
||||
#define URL_DEFAULTANON 1
|
||||
#define URL_NOSLASH 2
|
||||
extern void vfs_print_stats (char *fs_name, char *action, char *file_name, int have, int need);
|
||||
|
Loading…
Reference in New Issue
Block a user