%defattr
is usually used to set the default attributes for files/directories, so using it multiple times seems odd to me. First let's look at the %defattr
values: %defattr(file perms, user, group, dir perms)
. So probably the /var/log/testdir3 directory has permissions of 755 in your tarball since you're not setting the directory permissions, it's just inheriting them.
Try something like this:
%files
%defattr(755,root,root,777)
%dir /var/log/testdir1
%dir /var/log/testdir2
%dir /var/log/testdir3
Using what I have above, it will set the directories to 777, and then set all files that you list to 755 because it's inheriting the default values (both with ownership of root.root).
I'm still a bit confused as to why you're setting permissions on a log dir to 777, as when you declare the %dir it only sets the directory permissions. Are you not trying to set the files to something? If you need a specific directory with different permissions you should be using the %attr
attribute.