Bug 169885

Summary: logrotate cleanups and indentations
Product: [Fedora] Fedora Reporter: Mateus César Gröess <mateuscg>
Component: logrotateAssignee: Peter Vrabec <pvrabec>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: me, ro
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-10-12 13:00:44 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Cleanups and indentation fixes
none
Cleanups only, without the indentation changes. none

Description Mateus César Gröess 2005-10-04 18:40:30 UTC
Hi! New suggested patch (against logrotate-3.7.2-4), this time to do some
cleanups and fix indentation in logrotate (at least looks good when using my
good old VI and tab with size 8).

One question:

In logrotate.c (line 631 of 3.7.2-4), there is this code to mail and remove
logs, when LOG_FLAG_DATEEXT is used:

                            if (!hasErrors && log->logAddress) {
                                char * mailFilename =
(globResult.gl_pathv)[mail_out];
                                hasErrors = mailLogWrapper(mailFilename,
mailCommand, logNum, log);
                                if (!hasErrors)
                                    hasErrors = removeLogFile(mailFilename);
                            }

After the previous code, there is also this code (line 669) that do almost the
same when LOG_FLAG_DATEEXT isn't used:

                    char * mailFilename = (globResult.gl_pathv)[i];
                    if (!hasErrors && log->logAddress)
                        hasErrors = mailLogWrapper(mailFilename, mailCommand,
logNum, log);
                    if (!hasErrors)
                        hasErrors = removeLogFile(mailFilename);

Note that in second code the log removal doesn't depend on log->logAddress, but
the first do. Shouldn't both codes behave exactly the same way?

Comment 1 Mateus César Gröess 2005-10-04 18:40:31 UTC
Created attachment 119619 [details]
Cleanups and indentation fixes

Comment 2 Peter Vrabec 2005-10-07 08:34:50 UTC
I understand the first code(whole context), it drops old logs.
Example:
  rotatecount = 2
  foo
  foo-20051008
  foo-20051009
  foo-20051010
foo-20051008 should have not existed, because rotatecount==2, but if it
exists(somehow) it is removed in case mail address is provided.
I guess second code should do something similar but don't not how.

I suggest to do indention by  "indent -bsd"(I vote for bsd style)


Comment 3 Mateus César Gröess 2005-10-10 12:53:12 UTC
Created attachment 119770 [details]
Cleanups only, without the indentation changes.

Ok, I just proposed changes to correct bad indentation in some lines, haven't
used "indent". I attached another patch with cleanups only and a change to
second "if" described above, to make it act like the first. Maybe it's better
the maintainer do indentation changes according with his taste.

Comment 4 Ruediger Oertel 2005-10-10 23:52:01 UTC
well, according to the manpage, a to-be-removed logfile is 
- mailed out if an address is given 
- removed then, regardless if the address was given or not 
 
in that sense, I guess it is perfectly ok to remove the logfile 
in both code snippets, regardless if logAdress is set or not. 

Comment 5 Peter Vrabec 2005-10-12 13:00:03 UTC
Fixed in logrotate-3.7.2-6 in devel.
Indent will by apllied in next release 3.7.3.