Shadow like SQL

Shadow fatality by Sub Zero in Mortal Kombat.
Doesn't relate to post just for viewing only.
If you are using unix-like filesystems the most important thing for each user is shadow, "shadow is a file which contains the password information for the system´s accounts and optional ageing information" as described in man shadow. It stores actual password in encrypted format for user's account with additional properties related to user password.


Here is the declaration consists of a list of fields, of struct if you are using c.

struct spwd {
                 char          *sp_namp; /* user login name */
                 char          *sp_pwdp; /* encrypted password */
                 long int      sp_lstchg; /* last password change */
                 long int      sp_min; /* days until change allowed. */
                 long int      sp_max; /* days before change required */
                 long int      sp_warn; /* days warning for expiration */
                 long int      sp_inact; /* days before account inactive */
                 long int      sp_expire; /* date when account expires */
                 unsigned long int  sp_flag; /* reserved for future use */
           }
 Here is how the context of the shadow file looks like.
bin:*:14789:0:99999:7:::
daemon:*:14789:0:99999:7:::
adm:*:14789:0:99999:7:::
lp:*:14789:0:99999:7:::
sync:*:14789:0:99999:7:::
shutdown:*:14789:0:99999:7:::
halt:*:14789:0:99999:7:::
mail:*:14789:0:99999:7:::
uucp:*:14789:0:99999:7:::
operator:*:14789:0:99999:7:::
games:*:14789:0:99999:7:::
gopher:*:14789:0:99999:7:::

So now lets make SQL table for shadow.
CREATE TABLE IF NOT EXISTS `shadow` (
  `username` varchar(30) NOT NULL,
  `password` varchar(40) NOT NULL,
  `lstchg` datetime NOT NULL,
  `min` datetime NOT NULL,
  `max` datetime NOT NULL,
  `warn` datetime NOT NULL,
  `inact` datetime NOT NULL,
  `expire` datetime NOT NULL,
  `flag` text ,
  PRIMARY KEY (`username`)

Well that looks somehow the same but not thoroughly the same. Don't forget never use shadow as part of your title key because in SQL there is a command shadow and might conflict with your database in some way. Just avoid it just in case.

Comments

Popular Posts