summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/param/loadparm.c10
-rw-r--r--source3/passdb/mysqlpass.c103
-rw-r--r--source3/passdb/mysqlsampass.c59
-rw-r--r--source3/passdb/passdb.c7
-rw-r--r--source3/passdb/sampassdb.c2
-rw-r--r--source3/script/mysql_convert.pl77
6 files changed, 165 insertions, 93 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 845c2bd4e8..ccb314b2f1 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -231,7 +231,7 @@ typedef struct
BOOL bNTPipeSupport;
BOOL bStatCache;
BOOL bKernelOplocks;
-#if defined(WITH_MYSQL) || defined(WITH_MYSQLSAM)
+#if defined(HAVE_MYSQL_H) && defined(WITH_MYSQLSAM)
char *sMysqlDatabase;
char *sMysqlTable;
char *sMysqlUser;
@@ -754,14 +754,14 @@ static struct parm_struct parm_table[] =
{"ldap passwd file", P_STRING, P_GLOBAL, &Globals.szLdapPasswdFile, NULL, NULL, 0},
#endif /* WITH_LDAP */
-#if defined(WITH_MYSQL) || defined(WITH_MYSQLSAM)
+#if defined(HAVE_MYSQL_H) && defined(WITH_MYSQLSAM)
{"MySQL Options", P_SEP, P_SEPARATOR},
{"mysql host", P_STRING, P_GLOBAL, &Globals.sMysqlHost, NULL, NULL, 0},
{"mysql user", P_STRING, P_GLOBAL, &Globals.sMysqlUser, NULL, NULL, 0},
{"mysql pass file", P_STRING, P_GLOBAL, &Globals.sMysqlPassFile, NULL, NULL, 0},
{"mysql database", P_STRING, P_GLOBAL, &Globals.sMysqlDatabase, NULL, NULL, 0},
{"mysql table", P_STRING, P_GLOBAL, &Globals.sMysqlTable, NULL, NULL, 0},
-#endif /* WITH_MYSQL */
+#endif /* MYSQL */
{"Miscellaneous Options", P_SEP, P_SEPARATOR},
@@ -986,7 +986,7 @@ static void init_globals(void)
*/
Globals.bKernelOplocks = True;
-#if defined(WITH_MYSQL) || defined(WITH_MYSQLSAM)
+#if defined(HAVE_MYSQL_H) && defined(WITH_MYSQLSAM)
string_set(&Globals.sMysqlHost,"localhost");
string_set(&Globals.sMysqlUser,"root");
string_set(&Globals.sMysqlPassFile,NULL);
@@ -1352,7 +1352,7 @@ FN_LOCAL_INTEGER(lp_printing,iPrinting)
FN_LOCAL_CHAR(lp_magicchar,magic_char)
-#if defined(WITH_MYSQL) || defined(WITH_MYSQLSAM)
+#if defined(HAVE_MYSQL_H) && defined(WITH_MYSQLSAM)
FN_GLOBAL_STRING(lp_mysql_host,&Globals.sMysqlHost)
FN_GLOBAL_STRING(lp_mysql_user,&Globals.sMysqlUser)
FN_GLOBAL_STRING(lp_mysql_passfile,&Globals.sMysqlPassFile)
diff --git a/source3/passdb/mysqlpass.c b/source3/passdb/mysqlpass.c
index 90a6011692..c27cf708a6 100644
--- a/source3/passdb/mysqlpass.c
+++ b/source3/passdb/mysqlpass.c
@@ -21,10 +21,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#if defined(WITH_MYSQL) || defined(WITH_MYSQLSAM)
+#if defined(HAVE_MYSQL_H) || defined(WITH_MYSQLSAM)
#include "includes.h"
-#include <mysql.h>
extern int DEBUGLEVEL;
@@ -37,25 +36,6 @@ extern int DEBUGLEVEL;
#define FLAGS(row) ((*row)[6])
#define CHANGE_TIME(row) ((*row)[7])
-void *mysql_fill_smb_passwd( MYSQL_ROW *row );
-
-typedef void *(*mysql_fill_func)( MYSQL_ROW * );
-#define FILL_SMB mysql_fill_smb_passwd
-
-void *mysql_startpwent(BOOL update);
-void mysql_endpwent(void *vp);
-SMB_BIG_UINT mysql_getpwpos(void *vp);
-BOOL mysql_setpwpos(void *vp, SMB_BIG_UINT pos);
-void *mysql_fill_smb_passwd( MYSQL_ROW *row );
-MYSQL_ROW *mysql_getpwent(void *vp);
-void *mysql_fetch_passwd( mysql_fill_func filler, char *where );
-void *mysql_getpwuid( mysql_fill_func filler, uid_t uid );
-void *mysql_getpwnam( mysql_fill_func filler, char *field, const char *name );
-int mysql_db_lock_connect( MYSQL *handle );
-BOOL mysql_add_smb( MYSQL *handle, struct smb_passwd *smb );
-BOOL mysql_mod_smb( MYSQL *handle, struct smb_passwd *smb, BOOL override );
-BOOL mysql_del_smb( MYSQL *handle, char *unix_name );
-
static fstring mysql_table = { 0 };
struct mysql_struct {
@@ -65,7 +45,8 @@ struct mysql_struct {
};
typedef struct mysql_struct mysql_ctrl;
-static char *mysql_retrieve_password(char *passfile) {
+static char *mysql_retrieve_password(char *passfile)
+{
static fstring pass;
static time_t last_checked = (time_t)0;
static char pass_chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()_-+=|~`\\{}[]:;\"'?/>.<,";
@@ -113,7 +94,8 @@ static char *mysql_retrieve_password(char *passfile) {
return pass;
}
-static int mysql_db_connect( MYSQL *handle ) {
+static int mysql_db_connect( MYSQL *handle )
+{
char *password;
DEBUG(5,("%s\n",FUNCTION_MACRO));
@@ -136,7 +118,8 @@ static int mysql_db_connect( MYSQL *handle ) {
return 0;
}
-static int mysql_lock_table( MYSQL *handle, BOOL write_access ) {
+static int mysql_lock_table( MYSQL *handle, BOOL write_access )
+{
fstring query;
DEBUG(5,("%s\n",FUNCTION_MACRO));
@@ -151,7 +134,8 @@ static int mysql_lock_table( MYSQL *handle, BOOL write_access ) {
return 0;
}
-int mysql_db_lock_connect( MYSQL *handle ) {
+int mysql_db_lock_connect( MYSQL *handle )
+{
DEBUG(5,("%s\n",FUNCTION_MACRO));
@@ -167,7 +151,8 @@ int mysql_db_lock_connect( MYSQL *handle ) {
return 0;
}
-static MYSQL_RES *mysql_select_results( MYSQL *handle, char *selection ) {
+static MYSQL_RES *mysql_select_results( MYSQL *handle, char *selection )
+{
MYSQL_RES *result;
pstring query;
int query_length;
@@ -220,7 +205,8 @@ static MYSQL_RES *mysql_select_results( MYSQL *handle, char *selection ) {
return result;
}
-void *mysql_startpwent( BOOL update ) {
+void *mysql_startpwent( BOOL update )
+{
mysql_ctrl *mysql;
DEBUG(5,("%s\n",FUNCTION_MACRO));
@@ -254,7 +240,8 @@ void *mysql_startpwent( BOOL update ) {
return (void*)mysql;
}
-void mysql_endpwent( void *ptr ) {
+void mysql_endpwent( void *ptr )
+{
mysql_ctrl *handle;
DEBUG(5,("%s\n",FUNCTION_MACRO));
@@ -267,24 +254,27 @@ void mysql_endpwent( void *ptr ) {
free( handle );
}
-SMB_BIG_UINT mysql_getpwpos(void *vp) {
+SMB_BIG_UINT mysql_getpwpos(void *vp)
+{
DEBUG(5,("%s\n",FUNCTION_MACRO));
return ((mysql_ctrl *)vp)->current_row;
}
-BOOL mysql_setpwpos(void *vp, SMB_BIG_UINT pos) {
+BOOL mysql_setpwpos(void *vp, SMB_BIG_UINT pos)
+{
DEBUG(5,("%s\n",FUNCTION_MACRO));
mysql_data_seek( ((mysql_ctrl*)vp)->result, (uint)pos );
-((mysql_ctrl *)vp)->current_row=(uint)pos;
+ ((mysql_ctrl *)vp)->current_row=(uint)pos;
return True;
}
-static void quote_hash( char *target, unsigned char *passwd ) {
+static void quote_hash( char *target, unsigned char *passwd )
+{
char hex[] = "0123456789ABCDEF";
int i;
@@ -303,7 +293,8 @@ static void quote_hash( char *target, unsigned char *passwd ) {
}
}
-static unsigned char *decode_hash( char *hash, unsigned char *buffer ) {
+static unsigned char *decode_hash( char *hash, unsigned char *buffer )
+{
char hex[] = "0123456789ABCDEF";
int pos, v1, v2;
@@ -328,7 +319,8 @@ static unsigned char *decode_hash( char *hash, unsigned char *buffer ) {
return buffer;
}
-void *mysql_fill_smb_passwd( MYSQL_ROW *row ) {
+void *mysql_fill_smb_passwd( MYSQL_ROW *row )
+{
static struct smb_passwd pw_buf;
static fstring unix_name;
static fstring nt_name;
@@ -373,7 +365,8 @@ void *mysql_fill_smb_passwd( MYSQL_ROW *row ) {
return (void*)&pw_buf;
}
-MYSQL_ROW *mysql_getpwent(void *vp) {
+MYSQL_ROW *mysql_getpwent(void *vp)
+{
mysql_ctrl *mysql;
static MYSQL_ROW row;
@@ -391,14 +384,16 @@ MYSQL_ROW *mysql_getpwent(void *vp) {
return &row;
}
-struct smb_passwd *mysql_getsmbpwent(void *vp) {
+struct smb_passwd *mysql_getsmbpwent(void *vp)
+{
DEBUG(5,("%s\n",FUNCTION_MACRO));
return (struct smb_passwd*)mysql_fill_smb_passwd( mysql_getpwent(vp) );
}
-void *mysql_fetch_passwd( mysql_fill_func filler, char *where ) {
+void *mysql_fetch_passwd( mysql_fill_func filler, char *where )
+{
void *retval;
MYSQL handle;
MYSQL_RES *result;
@@ -447,7 +442,8 @@ void *mysql_fetch_passwd( mysql_fill_func filler, char *where ) {
return retval;
}
-void *mysql_getpwuid(mysql_fill_func filler, uid_t uid) {
+void *mysql_getpwuid(mysql_fill_func filler, uid_t uid)
+{
fstring where;
DEBUG(5,("%s\n",FUNCTION_MACRO));
@@ -457,14 +453,16 @@ void *mysql_getpwuid(mysql_fill_func filler, uid_t uid) {
return mysql_fetch_passwd(filler,where);
}
-struct smb_passwd *mysql_getsmbpwuid(uid_t uid) {
+struct smb_passwd *mysql_getsmbpwuid(uid_t uid)
+{
DEBUG(5,("%s\n",FUNCTION_MACRO));
- return (struct smb_passwd *)mysql_getpwuid( FILL_SMB, uid );
+ return (struct smb_passwd *)mysql_getpwuid( mysql_fill_smb_passwd, uid );
}
-void *mysql_getpwnam(mysql_fill_func filler, char *field, const char *name) {
+void *mysql_getpwnam(mysql_fill_func filler, char *field, const char *name)
+{
fstring where;
char format[] = "%s='%s'";
@@ -495,13 +493,15 @@ void *mysql_getpwnam(mysql_fill_func filler, char *field, const char *name) {
return mysql_fetch_passwd( filler, where );
}
-struct smb_passwd *mysql_getsmbpwnam(const char *unix_name) {
+struct smb_passwd *mysql_getsmbpwnam(const char *unix_name)
+{
DEBUG(5,("%s\n",FUNCTION_MACRO));
- return mysql_getpwnam( FILL_SMB, "unix_name", unix_name );
+ return mysql_getpwnam( mysql_fill_smb_passwd, "unix_name", unix_name );
}
-static void quote_string(char *target, char *string) {
+static void quote_string(char *target, char *string)
+{
DEBUG(5,("%s\n",FUNCTION_MACRO));
if ( string == NULL ) {
@@ -514,7 +514,8 @@ static void quote_string(char *target, char *string) {
}
}
-BOOL mysql_del_smb( MYSQL *handle, char *unix_name ) {
+BOOL mysql_del_smb( MYSQL *handle, char *unix_name )
+{
pstring query;
char format[] = "delete from %s where unix_name='%s'";
@@ -534,7 +535,8 @@ BOOL mysql_del_smb( MYSQL *handle, char *unix_name ) {
return True;
}
-BOOL mysql_add_smb( MYSQL *handle, struct smb_passwd *smb ) {
+BOOL mysql_add_smb( MYSQL *handle, struct smb_passwd *smb )
+{
pstring query;
char format[] = "insert into %s (unix_name, unix_uid) values ( '%s', %lu )";
@@ -555,7 +557,8 @@ BOOL mysql_add_smb( MYSQL *handle, struct smb_passwd *smb ) {
return True;
}
-BOOL mysql_mod_smb( MYSQL *handle, struct smb_passwd *smb, BOOL override ) {
+BOOL mysql_mod_smb( MYSQL *handle, struct smb_passwd *smb, BOOL override )
+{
pstring query;
fstring smb_passwd;
fstring smb_nt_passwd;
@@ -595,7 +598,8 @@ BOOL mysql_mod_smb( MYSQL *handle, struct smb_passwd *smb, BOOL override ) {
return True;
}
-BOOL mysql_add_smbpwd_entry(struct smb_passwd *smb) {
+BOOL mysql_add_smbpwd_entry(struct smb_passwd *smb)
+{
MYSQL handle;
DEBUG(5,("%s\n",FUNCTION_MACRO));
@@ -623,7 +627,8 @@ BOOL mysql_add_smbpwd_entry(struct smb_passwd *smb) {
return True;
}
-BOOL mysql_mod_smbpwd_entry(struct smb_passwd *smb, BOOL override) {
+BOOL mysql_mod_smbpwd_entry(struct smb_passwd *smb, BOOL override)
+{
MYSQL handle;
DEBUG(5,("%s\n",FUNCTION_MACRO));
diff --git a/source3/passdb/mysqlsampass.c b/source3/passdb/mysqlsampass.c
index 8d3049ce0a..e39bd61633 100644
--- a/source3/passdb/mysqlsampass.c
+++ b/source3/passdb/mysqlsampass.c
@@ -21,34 +21,17 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef WITH_MYSQLSAM
+#if defined(HAVE_MYSQL_H) && defined(WITH_MYSQLSAM)
#include "includes.h"
-#include <mysql.h>
extern int DEBUGLEVEL;
extern pstring samlogon_user;
extern BOOL sam_logon_in_ssb;
-typedef void *(*mysql_fill_func)( MYSQL_ROW * );
-#define FILL_SAM mysql_fill_sam_passwd
-
-void *mysql_startpwent(BOOL update);
-void mysql_endpwent(void *vp);
-SMB_BIG_UINT mysql_getpwpos(void *vp);
-BOOL mysql_setpwpos(void *vp, SMB_BIG_UINT pos);
-void *mysql_fill_smb_passwd( MYSQL_ROW *row );
-MYSQL_ROW *mysql_getpwent(void *vp);
-void *mysql_fetch_passwd( mysql_fill_func filler, char *where );
-void *mysql_getpwuid( mysql_fill_func filler, uid_t uid );
-void *mysql_getpwnam( mysql_fill_func filler, char *field, const char *name );
-int mysql_db_lock_connect( MYSQL *handle );
-BOOL mysql_add_smb( MYSQL *handle, struct smb_passwd *smb );
-BOOL mysql_mod_smb( MYSQL *handle, struct smb_passwd *smb, BOOL override );
-BOOL mysql_del_smb( MYSQL *handle, char *unix_name );
-
-void *mysql_fill_sam_passwd( MYSQL_ROW *row ) {
+void *mysql_fill_sam_passwd( MYSQL_ROW *row )
+{
static struct sam_passwd *user;
static pstring full_name;
@@ -112,66 +95,75 @@ void *mysql_fill_sam_passwd( MYSQL_ROW *row ) {
return (void*)user;
}
-struct sam_passwd *mysql_getsampwent(void *vp) {
+struct sam_passwd *mysql_getsampwent(void *vp)
+{
DEBUG(5,("%s\n",FUNCTION_MACRO));
return (struct sam_passwd*)mysql_fill_sam_passwd( mysql_getpwent(vp) );
}
-struct sam_passwd *mysql_getsampwrid(uint32 rid) {
+struct sam_passwd *mysql_getsampwrid(uint32 rid)
+{
fstring where;
DEBUG(5,("%s\n",FUNCTION_MACRO));
slprintf( where, sizeof(where), "user_rid=%lu", (long unsigned)rid);
- return (struct sam_passwd *)mysql_fetch_passwd( FILL_SAM, where );
+ return (struct sam_passwd *)mysql_fetch_passwd( mysql_fill_sam_passwd, where );
}
-struct sam_passwd *mysql_getsampwuid(uid_t uid) {
+struct sam_passwd *mysql_getsampwuid(uid_t uid)
+{
DEBUG(5,("%s\n",FUNCTION_MACRO));
- return (struct sam_passwd *)mysql_getpwuid( FILL_SAM, uid );
+ return (struct sam_passwd *)mysql_getpwuid( mysql_fill_sam_passwd, uid );
}
-struct sam_passwd *mysql_getsampwntnam(const char *nt_name) {
+struct sam_passwd *mysql_getsampwntnam(const char *nt_name)
+{
DEBUG(5,("%s\n",FUNCTION_MACRO));
- return (struct sam_passwd *)mysql_getpwnam( FILL_SAM, "nt_name", nt_name);
+ return (struct sam_passwd *)mysql_getpwnam( mysql_fill_sam_passwd, "nt_name", nt_name);
}
-struct sam_disp_info *mysql_getsamdispntnam(const char *nt_name) {
+struct sam_disp_info *mysql_getsamdispntnam(const char *nt_name)
+{
DEBUG(5,("%s\n",FUNCTION_MACRO));
return pwdb_sam_to_dispinfo(mysql_getsampwntnam(nt_name));
}
-struct sam_disp_info *mysql_getsamdisprid(uint32 rid) {
+struct sam_disp_info *mysql_getsamdisprid(uint32 rid)
+{
DEBUG(5,("%s\n",FUNCTION_MACRO));
return pwdb_sam_to_dispinfo(mysql_getsampwrid(rid));
}
-struct sam_disp_info *mysql_getsamdispent(void *vp) {
+struct sam_disp_info *mysql_getsamdispent(void *vp)
+{
DEBUG(5,("%s\n",FUNCTION_MACRO));
return pwdb_sam_to_dispinfo(mysql_getsampwent(vp));
}
-static BOOL mysql_mod_sam( MYSQL *handle, struct sam_passwd *sam, BOOL override ) {
+static BOOL mysql_mod_sam( MYSQL *handle, struct sam_passwd *sam, BOOL override )
+{
DEBUG(5,("%s\n",FUNCTION_MACRO));
return True;
}
-BOOL mysql_add_sampwd_entry(struct sam_passwd *sam) {
+BOOL mysql_add_sampwd_entry(struct sam_passwd *sam)
+{
MYSQL handle;
struct smb_passwd *smb;
@@ -208,7 +200,8 @@ BOOL mysql_add_sampwd_entry(struct sam_passwd *sam) {
return True;
}
-BOOL mysql_mod_sampwd_entry(struct sam_passwd *sam, BOOL override) {
+BOOL mysql_mod_sampwd_entry(struct sam_passwd *sam, BOOL override)
+{
MYSQL handle;
struct smb_passwd *smb;
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index 9936dd2293..39caef2f85 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -70,7 +70,7 @@ BOOL initialise_password_db(void)
pwdb_ops = nisplus_initialise_password_db();
#elif defined(WITH_LDAP)
pwdb_ops = ldap_initialise_password_db();
-#elif defined(WITH_MYSQL) || defined(WITH_MYSQLSAM)
+#elif defined(HAVE_MYSQL_H) && defined(WITH_MYSQLSAM)
pwdb_ops = mysql_initialise_password_db();
#elif defined(USE_SMBPASS_DB)
pwdb_ops = file_initialise_password_db();
@@ -278,6 +278,11 @@ struct smb_passwd *pwdb_smb_map_names(struct smb_passwd *smb)
{
return NULL;
}
+ if (smb->unix_name != NULL && smb->nt_name != NULL &&
+ smb->unix_uid != (uid_t)-1 && smb->user_rid != 0xffffffff)
+ {
+ return smb;
+ }
if (!found && smb->unix_name != NULL)
{
diff --git a/source3/passdb/sampassdb.c b/source3/passdb/sampassdb.c
index a4c981b160..e80d157ec0 100644
--- a/source3/passdb/sampassdb.c
+++ b/source3/passdb/sampassdb.c
@@ -70,7 +70,7 @@ BOOL initialise_sam_password_db(void)
pwdb_ops = nisplus_initialise_sam_password_db();
#elif defined(WITH_LDAP)
pwdb_ops = ldap_initialise_sam_password_db();
-#elif defined(WITH_MYSQLSAM)
+#elif defined(HAVE_MYSQL_H) && defined(WITH_MYSQLSAM)
pwdb_ops = mysql_initialise_sam_password_db();
#elif defined(USE_SMBPASS_DB)
pwdb_ops = file_initialise_sam_password_db();
diff --git a/source3/script/mysql_convert.pl b/source3/script/mysql_convert.pl
index e9c1b9de56..1479ce62b7 100644
--- a/source3/script/mysql_convert.pl
+++ b/source3/script/mysql_convert.pl
@@ -1,6 +1,73 @@
-#!/usr/local/bin/perl
-
-use Mysql;
+#!/bin/env perl
+#
+# MYSQL Convert - Creates and initialises mysql tables for use by samba
+#
+# Copyright (C) Benjamin Kuit 1999,
+# Copyright (C) Andrew Tridgell 1992-1999,
+# Copyright (C) Luke Kenneth Casson Leighton 1996-1998,
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+#
+# Converts smbpasswd files into MySQL tables.
+# Can understand Samba 1.19 and Samba 2.0 file formats.
+# Assumes table structure:
+# unix_name char(20) not null,
+# unix_uid int(10) unsigned not null,
+# nt_name char(20) not null,
+# user_rid int(10) unsigned not null,
+# smb_passwd char(32),
+# smb_nt_passwd char(32),
+# acct_ctrl int(10) unsigned not null,
+# pass_last_set_time int(10) unsigned not null,
+# unique (unix_name),
+# unique (unix_uid)
+# When given the --create option, mysql_convert will generate this
+# statement.
+#
+# To move from flat file smbpasswd directly into a mysql table:
+#
+# mysql_convert.pl --db=samba --table=smbpasswd --user=samba --create --infile=smbpasswd
+#
+# Assumes mysql server on localhost, use --host if otherwise.
+# To convert back to flat file:
+#
+# mysql_convert.pl --db=samba --table=smbpasswd --user=samba --outfile=smbpasswd
+#
+# If smbpasswd file already exists, use --file=append or --file=trash
+# to determine whether to append or over-right the file.
+#
+# In converting from NT Server PDC to Samba PDC:
+# Run pwdump on NT Server to generate an smbpasswd file (Samba 1.19 format),
+# called say NTpasslist.
+# then:
+#
+# mysql_convert.pl --db=samba --table=smbpasswd --user=samba --infile=NTpasslist --create --check
+#
+# The --check option will change the unix_uid field to the real uid
+# value of respective users, also filter out users that dont exist on
+# the system.
+#
+# If dont have mysql perl module:
+#
+# mysql_convert.pl --table=smbpasswd --infile=NTpasslist --outfile=mysql.txt
+#
+# Then use the mysql client:
+#
+# mysql -u samba < mysql.txt
+#
$ACB_DISABLED=0x0001;
$ACB_HOMDIRREQ=0x0002;
@@ -17,7 +84,7 @@ $ACB_AUTOLOCK=0x0400;
sub getoptionval {
my ($option) = @_;
- my ($value) = ($option =~ /^[^=]+=\s*(\S.*\S)/ );
+ my ($value) = ($option =~ /^[^=]+=\s*(\S.*\S)\s*$/ );
return $value;
}
@@ -240,6 +307,8 @@ elsif ( (not $dbname) || (not $dbtable) || (not $dbuser) ) {
&usage;
}
else {
+ use Mysql;
+
if ( ($need_password eq "yes") && ( not $dbpasswd )) {
$dbpasswd = getpass("Enter MySQL password for $dbuser: ");
}