How to fix corrupt keychain permissions I have change permission of /var location by mistake with 777 and  now my Keychain Access not working  fine (i have stop chmod but some file and folder's permission  are  change  ) 

folder in var location  with permission 

drwxr-xr-x   26 root       wheel       884 Jul  8 22:02 .
drwxr-xr-x@   6 root       wheel       204 Jan 23  2015 ..
drwxrwxrwt    3 root       wheel       102 Mar 24  2015 Keychains
drwxrwxrwx    2 root       wheel        68 Sep 10  2014 agentx
drwxrwxrwx    8 daemon     wheel       272 Jan 23  2015 at
drwxrwxrwx  101 root       wheel      3434 Jul  8 20:49 audit
drwxrwxrwx    2 root       wheel        68 Sep 10  2014 backups
drwx------   72 root       wheel      2448 Jul  9 09:19 db
drwxrwxrwx    3 root       sys         102 Jul  9 01:57 empty
drwx------    5 root       wheel       170 Jul  2  2015 folders
drwxrwxrwx    2 _jabber    _jabber      68 Sep 10  2014 jabberd
drwxrwxrwx    3 root       wheel       102 Sep 10  2014 lib
drwxrwxrwx   65 root       wheel      2210 Jul  9 10:46 log
drwxrwxrwx    4 root       wheel       136 Dec 18  2015 logs
drwxrwxrwx    3 root       mail        102 Jul  9 10:50 mail
drwxrwxrwx    3 root       wheel       102 Jan 23  2015 msgs
drwxrwxrwx    2 root       wheel        68 Sep 10  2014 netboot
drwxrwxrwx    2 _networkd  _networkd    68 Sep 10  2014 networkd
drwxrwxrwx   14 root       wheel       476 Jul  8 23:32 root
drwxrwxrwx    4 root       wheel       136 Sep 10  2014 rpc
drwxrwxrwx   30 root       daemon     1020 Jul  9 10:37 run
drwxrwxrwx    2 daemon     wheel        68 Sep 10  2014 rwho
drwxrwxrwx    7 root       wheel       238 Jan 23  2015 spool
drwxrwxrwt   31 root       wheel      1054 Jul  9 10:54 tmp
drwxrwxrwx    3 root       wheel       102 Jul  9 01:36 vm
drwxrwxrwx    3 root       wheel       102 Sep 10  2014 yp


login and system Keychain are in  read-only with not item display 

when i try to first ads then 

Repair started
Checking keychain configuration for patel (user ID=501)
Home directory is /Users/patel
Checked login keychain
Unable to open ~/Library/Keychains/login.keychain (-25312)
Renamed /Users/patel/Library/Keychains/login.keychain to /Users/patel/Library/Keychains/login_renamed.keychain
Repair terminated unexpectedly


when try to reset then 

A Module Directory Service error has occurred. 


when try to create new keychain  then 

An error occurred while creating a new keychain.


and some time i have got 

"Unapproved Caller", "SecurityAgent may only be invoked by Apple Software".


any help to restore var folder permission
Make sure /Library/Keychains/System.keychain has correct permissions set.

Here is default permissions for /Library/Keychains folder on my Mac:

drwxr-xr-x    9 root  wheel   306 10 Jul 20:03 Keychains

and default permissions for /Library/Keychains/System.keychain

-rw-r--r--  1 root  wheel  124000  7 Jul 05:38 System.keychain

Also check permissions for your user keychain folder, mine are for the folder ~/Library/Keychains/:

drwxr-xr-x    9 username  staff    306 10 Jul 21:49 Keychains

and the user keychains itself:

drwx------  7 username  staff      238 25 Mar 13:36 A2676C22-A84E-5B3D-8711-0264BC3C8B96
-rw-r--r--  1 username  staff      277 21 Mar 07:28 E41FE5C0-3020-48C9-8829-344FF3E86407

Here is the default permission for /var on my Mac.

lrwxr-xr-x@   1 root  wheel    11 14 Jan 15:39 var -&gt; private/var

Here are the default permissions for everything inside of my /var folder.

drwx------     2 root       wheel          68 24 Oct  2015 agentx
drwxr-xr-x     8 daemon     wheel         272 14 Jan 13:00 at
drwx------  7107 root       wheel      241638 10 Jul 20:03 audit
drwx------     2 root       wheel          68 16 Sep  2015 backups
drwxr-xr-x    77 root       wheel        2618 10 Jul 20:03 db
drwxr-x---     3 _dovecot   mail          102  9 Mar 12:12 dovecot
drwxr-xr-x     2 root       sys            68 16 Sep  2015 empty
drwxr-xr-x     7 root       wheel         238  4 Jun 10:47 folders
drwxr-x---     3 _jabber    _jabber       102  9 Mar 12:12 jabberd
drwxr-xr-x     3 root       wheel         102  1 Aug  2015 lib
drwxr-xr-x   106 root       wheel        3604 10 Jul 20:03 log
drwxrwxr-x     2 root       mail           68 16 Sep  2015 mail
drwxr-xr-x     3 root       wheel         102 16 Sep  2015 msgs
drwxr-xr-x     2 root       wheel          68 16 Sep  2015 netboot
drwxr-xr-x     5 _networkd  _networkd     170 25 Mar 18:36 networkd
drwxrwxr-x     2 _postgres  _postgres      68 27 May 09:22 pgsql_socket
drwxr-x---     6 root       wheel         204 27 May 09:22 root
drwxr-xr-x     4 root       wheel         136 24 Oct  2015 rpc
drwxrwxr-x    49 root       daemon       1666 10 Jul 21:29 run
drwxr-xr-x     2 daemon     wheel          68 16 Sep  2015 rwho
drwxr-xr-x    37 root       wheel        1258 10 Jul 21:29 servermgrd
drwxr-xr-x     7 root       wheel         238 14 Jan 13:01 spool
drwxrwxrwt    16 root       wheel         544 10 Jul 21:29 tmp
drwxr-xr-x     4 root       wheel         136 10 Jul 20:32 vm
drwxr-xr-x     3 root       wheel         102 16 Sep  2015 yp