how to connect to /etc/pwd


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to connect to /etc/pwd
# 1  
Old 09-21-2008
Data how to connect to /etc/pwd

i've been searching the way to connect to pwd.db file located in /etc/ directory..
since i'm not the root and only one of the users of the server, i need to connect to the database so that i can make a login page for all users of the server..
the file is readable by all users and the permission to the file is like:
Quote:
-rw-r--r-- 1 root wheel 139264 Jul 8 16:50 pwd.db
i need to know how should i connect to the database using php command..

i've been searching some code to do that but it returns nothing..
these two codes are the example of what i have tried:

as u can see this is the common php script:
Quote:
<?php
session_start();

require_once('config.php');

//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db=mysql_select_db(DB_DATABASE);
/*$db = dba_open( '/etc/pwd.db', 'r', 'dbm' );*/
if(!$db) {
die("Unable to select database");
}

/* else{
print "alias for root is: " . dba_fetch( "root\0", $db ) . "\n";
dba_close($db);
}*/

/* //Sanitize the value received from login field
//to prevent SQL Injection
if(!get_magic_quotes_gpc()) {
$login=mysql_real_escape_string($_POST['login']);
}else {
$login=$_POST['login'];
}*/

//Create query
$qry="SELECT * FROM pwd WHERE name='$name' AND password='".md5($_POST['password'])."'";
$result=mysql_query($qry);
//Check whether the query was successful or not
if($result) {
/* if(mysql_num_rows($result)>0) {
//Login Successful
session_regenerate_id();
$member=mysql_fetch_assoc($result);
$_SESSION['SESS_MEMBER_ID']=$member['uid'];
session_write_close();*/
header("location: userlogin.html");
exit();
}else {
//Login failed
header("location: userlogin.php");
exit();
}
}else {
die("Query failed");
}
?>
while this code is an ADOdb code:
Quote:
<?php
include('/path/to/adodb.inc.php');
$DB = NewADOConnection('mysql');
$DB->Connect($server, $user, $pwd, $db);

# M'soft style data retrieval with binds $rs = $DB->Execute("select * from
table where key=?",array($key)); while (!$rs->EOF) {
print_r($rs->fields);
$rs->MoveNext();
}


ACCESS::

<?
include('adodb.inc.php'); # load code common to ADOdb
$conn = &ADONewConnection('access'); # create a connection
$conn->PConnect('northwind'); # connect to MS-Access, northwind DSN
$recordSet = &$conn->Execute('select * from products'); if (!$recordSet)
print $conn->ErrorMsg();
else
while (!$recordSet->EOF) {
print $recordSet->fields[0].' '.$recordSet->fields[1].'<BR>';
$recordSet->MoveNext();
}

$recordSet->Close(); # optional
$conn->Close(); # optional

?>
i can do this coding if it is in windows and if i'm the root..but since i'm not and the file is located in /etc/ and it is in Unix..i didn't really know how to connect it..please tell me what is wrong with the code or should i recreate another code?
# 2  
Old 10-09-2008
I read half your message and thought, "What, is the user thinking in Windows??". Sure enough. Smilie Normally a .db file is accessed through the DBA interface... dba_open, dba_close, etc. The values stored therein are strictly "key/value" pairs. There are no selects or queries. Just keys (a string that's like a unique column index) and a value (like the entire row). You don't "connect" to it -- you just open it, and you have to be on the local host. If it's in the /etc/ directory, that's no problem, but it should be world-readable and/or readable by the group running the web server. If you want to make changes, then you need to make it world-writable (or group-writable).
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Connect direct - SFTP - List of servers that I can connect

Greetings Experts, I am working for a bank client and have a question on connect-direct and SFTP. We are using Linux RedHat servers. We use connect-direct to transfer (NDM) files from one server to another server. At times, we manually transfer the files using SFTP from one server to another... (2 Replies)
Discussion started by: chill3chee
2 Replies

2. UNIX for Beginners Questions & Answers

$pwd

Hi all,when I cd to an environment variable "cd $MYDIR, if I type pwd, I don't the path to the environment variable dir I cd to. Appreciate the help, regards..Abbya (5 Replies)
Discussion started by: abbya
5 Replies

3. Cybersecurity

When i start CSF i cant connect VPS or download any data into it It appears i cant connect Linux VP?

It appears i cant connect linux VPS server via SSH or i cant SCP any file to it and i cant wget any file TO it (from inside it) while CSF (Config Server Firewall, LFD is running. Just after isntall in default configuration and after changing TESTING mode to LIVE mode. Trying to wget & install... (1 Reply)
Discussion started by: postcd
1 Replies

4. AIX

AIX Remote Connect Fail With “No more multiple IP addresses to connect” Error

We have a production server at a client site running AIX. And recently when users are trying to connect to it via telnet, it prompts "No more multiple IP addresses to connect". Can I know what does this error mean? and how to rectify this? Thanks. (2 Replies)
Discussion started by: a_sim
2 Replies

5. UNIX for Dummies Questions & Answers

$PWD vs `pwd`

Hi, can anyone expalin the real importance of PWD as a variable. However pwd command and $PWD is going to give the same result, then why do we have 2 different things. Please give some example which illustrates the difference between both. Thanks (9 Replies)
Discussion started by: pandeesh
9 Replies

6. UNIX for Dummies Questions & Answers

pwd help

Dear users, One more question, In unix when i use pwd the following I get: pwd /Users/username/src/directory name Is there a way to get the out put like this in which the if there is a space in the directory eg directory name it should show as directory\ name:... (2 Replies)
Discussion started by: kevincobain2000
2 Replies

7. AIX

sync samba pwd with aix5.3 pwd

currently, my samba login works just fine. i want my clients to use aix5.3 account to login to samba so they don't have to change samba pwd and aix pwd. i googled, and vi /usr/lib/smb.conf per some of knowledge base, but i could not get to work. aix5.3 and samba 3.0.24.0 thanks in advace..... (2 Replies)
Discussion started by: tjmannonline
2 Replies

8. UNIX for Advanced & Expert Users

echo ${PWD#${PWD%/*/*}/}

Can anyone explain this in detail ... echo ${PWD#${PWD%/*/*}/} Thanks in Advance (1 Reply)
Discussion started by: sakthi.abdullah
1 Replies

9. UNIX for Dummies Questions & Answers

pwd

Home directory mounted on one local system as /home/username, same directory mounted on a remote system as /home/engr/username. How to use command to use remote host pwd. For example rsh <remote host> ls -l ~pwd (2 Replies)
Discussion started by: bugsandbunny
2 Replies

10. Shell Programming and Scripting

help on PWD

Hi, We all know that pwd (or echo $PWD) gives us the present working dir as output.... but my doubt is that I'ld like to know how to get the present working folder - I mean - name of the current folder alone.. using pwd command I get the full folder name (right from root path)... I need to know... (2 Replies)
Discussion started by: mohanprabu
2 Replies
Login or Register to Ask a Question