During this, i’v been writing scanvirusbin code. I’v finished the permissions code. It now creates the needed files and checkpermisions. File username and groupname is for another topic. The code is written out based on the usual gathering of info. There might be problems with it.
I can’t use fprint with the config file. Since, it includes ‘%’ symbol, more maybe added later.
//create config file if not present
File_Found= stat(VirusConfig, &file_stats);
if (File_Found != 0)
{
FilePtr=fopen(VirusConfig, "w");
if (FilePtr != NULL)
{
fputs("______________________________scanvirus configuration______________________________
", FilePtr);
fputs("date +'%Y-%m-%d %I:%M:%S%P'
", FilePtr);
fputs("TimeStamp= %I:%M:%S%P
", FilePtr);
fputs("DateStamp= %Y-%m-%d
", FilePtr);
fputs("______________________________________________________________________________
", FilePtr);
fputs("ExcludedScanFolders= dev etc kdeinit5__0 proc tmp srv sys var .snapshots
", FilePtr);
fputs("___________________________________________________________________________________
", FilePtr);
fputs("Bash Suspend Command
", FilePtr);
fputs("1= 'systemctl suspend' - openSUSE, Ubuntu, Fedora, Arch, Debian, etc
", FilePtr);
fputs("2= 'pm-suspend' - Void, Gentoo, Devuan etc - pm-utils power management suite
", FilePtr);
fputs("SuspendCommand= 1
", FilePtr);
fputs("___________________________________________________________________________________
", FilePtr);
fputs("Suspend or power-off lock screen - GNOME KDE
", FilePtr);
fputs("LockScreenCommand= 0
", FilePtr);
fputs("___________________________________________________________________________________
", FilePtr);
fputs("MSWIN scan - partition file system types
", FilePtr);
fputs("ScanPartitionFileSystems= ntfs vfat
", FilePtr);
fputs("___________________________________________________________________________________
", FilePtr);
fputs("List users group filter
", FilePtr);
fputs("UserGroupFilter= users
", FilePtr);
fputs("___________________________________________________________________________________
", FilePtr);
fputs("Scan Log Format
", FilePtr);
fputs("%o OS Type
", FilePtr);
fputs("%s Virus Status
", FilePtr);
fputs("%f Scan Folder
", FilePtr);
fputs("%n Scan Time
", FilePtr);
fputs("%c Command Options
", FilePtr);
fputs("%t Time Stamp
", FilePtr);
fputs("%d Date Stamp
", FilePtr);
fputs("
", FilePtr);
fputs("ScanLogFormat= %o %s %f %n %c %t %d
", FilePtr);
fputs("___________________________________________________________________________________
", FilePtr);
}
else
{
printf("can't write to file
");
return(-1);
}
fclose(FilePtr);
Can I shorten this code?