FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour dbf file extension
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
dbf file extension
Posted: Sun Mar 16, 2008 02:17 PM

Is it possible to rename the dbf files to something else. Only to obscure the database format you use.
example: customer.dbf customer.abc

Regards,
Otto

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
dbf file extension
Posted: Sun Mar 16, 2008 02:34 PM

Otto,

Yes, you can open them using the extension that you want or use RddInfo( RDDI_TABLEEXT, ".abc" ) so it will be used by default.

define RDDI_TABLEEXT 5 / Default data file's file extension /

define RDDI_MEMOEXT 6 / Default memo file's file extension /

define RDDI_ORDBAGEXT 7 / Default multi tag index's file extension /

define RDDI_ORDEREXT 8 / default single tag index's file extension /

define RDDI_ORDSTRUCTEXT 9 / default single tag index's file extension /

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
dbf file extension
Posted: Sun Mar 16, 2008 04:41 PM

The above method may be better.
But you can also simply open the file with extention
example:
USE CUSTOMER.ABC
But you should use the extention every where you open the table.

Regards



G. N. Rao.

Hyderabad, India
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
dbf file extension
Posted: Sun Mar 16, 2008 04:58 PM

Thank you.
Maybe this way you can keep off EXCEL user opening important files.
Regards,
Otto

Posts: 782
Joined: Wed Dec 19, 2007 07:50 AM
dbf file extension
Posted: Sun Mar 16, 2008 05:10 PM
Hi Otto:

There was an old trick in Clipper to hide dbfs to programs, it consisted in changing the first byte of dbf file (dbf file's first byte is always Chr(3)), something like this:
   If ( nHandle := FOpen( "MGFCES.DBF", 2 ) ) >= 0
    FSeek( nHandle, 0, 0 )
    FWrite( nHandle,Chr( 4 ), 1 )
    FClose( nHandle )
    FRename( "MGFCES.DBF", "MGFCES.ABC" )
   EndIf

Then when you wanted to use the dbf again, just restored the first byte to Chr(3)

Regards

Manuel Mercado
manuelmercado at prodigy dot net dot mx
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
dbf file extension
Posted: Sun Mar 16, 2008 05:16 PM

Always beware of Excel user, particularity if he is knowledgeable. Excel is so powerful that he can see and tinker with any RDMS ( oracle, mssql ) if he knows the passwords. ADS is, in a way, better. We can hide the folder to all except ADS. Still he can break through if ADS OLEDB is installed.

One of the aspects of database management is to keep it safe from hackers and this is another art / science.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
dbf file extension
Posted: Sun Mar 16, 2008 05:19 PM
mmercado wrote:Hi Otto:

There was an old trick in Clipper to hide dbfs to programs, it consisted in changing the first byte of dbf file (dbf file's first byte is always Chr(3)), something like this:
   If ( nHandle := FOpen( "MGFCES.DBF", 2 ) ) >= 0
    FSeek( nHandle, 0, 0 )
    FWrite( nHandle,Chr( 4 ), 1 )
    FClose( nHandle )
    FRename( "MGFCES.DBF", "MGFCES.ABC" )
   EndIf

Then when you wanted to use the dbf again, just restored the first byte to Chr(3)

Regards

Manuel Mercado

Yes it was an old trick. But not useful in multiuser environments. Works in single user environment
Regards



G. N. Rao.

Hyderabad, India
Posts: 654
Joined: Mon May 29, 2006 03:14 PM
dbf file extension
Posted: Sun Mar 16, 2008 05:59 PM
Some denominated function exists ISBDF() ?
Mi abuelo decía: Los aviones vuelan porque Dios quiere, y los helicópteros ni Dios sabe porque vuelan.

FWH 16.02, xHarbour 1.2.3, Harbour 3.2.0, WorkShop 4.5, AJ Make 0.30, Borlan BCC 7.00, VisualStudio 2013
Posts: 464
Joined: Tue May 16, 2006 07:47 AM
dbf file extension
Posted: Mon Mar 17, 2008 01:48 AM

Another idea is to make them hidden files. What the snooping Excel user doesn't see he possibly won't fiddle with. Just a thought.

xProgrammer

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
dbf file extension
Posted: Mon Mar 17, 2008 03:54 AM
xProgrammer wrote:Another idea is to make them hidden files. What the snooping Excel user doesn't see he possibly won't fiddle with. Just a thought.

xProgrammer

Yes. Good.
Need to do anything and everything to protect the data. Level of implementation depends on the assessment of the risks in the environment. Even assuming that somebody could still open the table, encryption helps to ensure that he does not understand the data. Again that does not prevent him from altering the data. Having some kind of checksum of important columns helps to know at least if there is any unauthorized change. Also meaningless table names and column names makes it difficult for the prying eye to know where to look for. Maintaining redundant columns or tables with encoded corresponding values helps restore correct data in case of unauthorized changes.

To repeat, it is an appropriate combination of measures that keeps data fairly safe. What measures we take depends on the assessment of the risks in a particular environment.
Regards



G. N. Rao.

Hyderabad, India
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
dbf file extension
Posted: Mon Mar 17, 2008 07:12 AM

To all,

Thank you for your help and suggestions.

Question:
Is there a function to hide files?
Regards,
Otto

Posts: 464
Joined: Tue May 16, 2006 07:47 AM
dbf file extension
Posted: Mon Mar 17, 2008 08:42 AM
Try SetFAttr() info below (I use Linux so can't test for you).

SetFAttr()
Sets file attributes.
Syntax
SetFAttr( <cFileName>, [<nAttributes>] ) --> nErrorCode
Arguments
<cFileName>
This is a character string holding the name of the file to set attributes for. It must include path
and file extension. If the path is omitted from <cFileName>, the file is searched in the current
directory only.
<nAttributes>
This is a numeric value specifying the file attributes to set. Values of the following list are used
for file attributes. To specifiy multiple attributes, pass the sum of the corresponding values:
Values for file attributes
           Value                             Attribute
           0                                 Normal
           1                                 Read only
           2                                 Hidden
           4                                 System
           8                                 Volume
           32                                Archived

Return
The function returns zero on success or a numeric error code on failure.
Info
See also: BitToC(), CtoBit(), FileAttr(), FileSeek()
Category: CT:DiskUtil, File functions, Low level file functions
Source: ct\files.c
LIB: xhb.lib
DLL: xhbdll.dll

Hope that helps
Regards
Doug
(xProgrammer)
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
dbf file extension
Posted: Mon Mar 17, 2008 09:26 AM

xProgrammer, thank you for your help.
Do you use xHarbour?
Regards, Otto

Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
dbf file extension
Posted: Mon Mar 17, 2008 09:56 AM

Otto

define FILE_ATTRIBUTE_NORMAL 128 // 0x00000080

define FILE_ATTRIBUTE_READONLY 1 // 0x00000001

define FILE_ATTRIBUTE_HIDDEN 2 // 0x00000002

define FILE_ATTRIBUTE_SYSTEM 4 // 0x00000004

define FILE_ATTRIBUTE_DIRECTORY 16 // 0x00000010

define FILE_ATTRIBUTE_ARCHIVE 32 // 0x00000020

define FILE_ATTRIBUTE_TEMPORARY 256 // 0x00000100

define FILE_ATTRIBUTE_COMPRESSED 2048 // 0x00000800

define FILE_ATTRIBUTE_OFFLINE 4096 // 0x00001000

SETFILEATTRIBUTES(yourfilename, FILE_ATTRIBUTE_NORMAL )

DLL32 FUNCTION SETFILEATTRIBUTES(cFileName AS LPSTR, nFileAttributes AS DWORD ) ;
AS BOOL PASCAL FROM "SetFileAttributesA" LIB "Kernel32.dll"

Hth

Richard

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
dbf file extension
Posted: Mon Mar 17, 2008 10:20 AM

Richard, thank you.

Regards,
Otto